diff --git a/Telegram/SourceFiles/history/history_widget.h b/Telegram/SourceFiles/history/history_widget.h index 50a7f88c1..e42bae30b 100644 --- a/Telegram/SourceFiles/history/history_widget.h +++ b/Telegram/SourceFiles/history/history_widget.h @@ -89,9 +89,6 @@ class TabbedSelector; namespace Storage { enum class MimeDataState; -struct UploadedPhoto; -struct UploadedDocument; -struct UploadedThumbDocument; } // namespace Storage namespace HistoryView { diff --git a/Telegram/SourceFiles/storage/file_upload.cpp b/Telegram/SourceFiles/storage/file_upload.cpp index cf6b232ed..912541ed8 100644 --- a/Telegram/SourceFiles/storage/file_upload.cpp +++ b/Telegram/SourceFiles/storage/file_upload.cpp @@ -172,24 +172,6 @@ Uploader::Uploader(not_null api) documentReady( ) | rpl::start_with_next([=](const UploadedDocument &data) { - if (data.edit) { - const auto item = session->data().message(data.fullId); - Api::EditMessageWithUploadedDocument( - item, - data.file, - std::nullopt, - data.options); - } else { - _api->sendUploadedDocument( - data.fullId, - data.file, - std::nullopt, - data.options); - } - }, _lifetime); - - thumbDocumentReady( - ) | rpl::start_with_next([=](const UploadedThumbDocument &data) { if (data.edit) { const auto item = session->data().message(data.fullId); Api::EditMessageWithUploadedDocument( @@ -206,7 +188,6 @@ Uploader::Uploader(not_null api) } }, _lifetime); - photoProgress( ) | rpl::start_with_next([=](const FullMsgId &fullId) { processPhotoProgress(fullId); @@ -500,31 +481,28 @@ void Uploader::sendNext() { MTP_int(uploadingData.docPartsCount), MTP_string(uploadingData.filename()), MTP_bytes(docMd5)); - if (uploadingData.partsCount) { + const auto thumb = [&]() -> std::optional { + if (!uploadingData.partsCount) { + return std::nullopt; + } const auto thumbFilename = uploadingData.file ? uploadingData.file->thumbname : (qsl("thumb.") + uploadingData.media.thumbExt); const auto thumbMd5 = uploadingData.file ? uploadingData.file->thumbmd5 : uploadingData.media.jpeg_md5; - const auto thumb = MTP_inputFile( + return MTP_inputFile( MTP_long(uploadingData.thumbId()), MTP_int(uploadingData.partsCount), MTP_string(thumbFilename), MTP_bytes(thumbMd5)); - _thumbDocumentReady.fire({ - uploadingId, - options, - file, - thumb, - edit }); - } else { - _documentReady.fire({ - uploadingId, - options, - file, - edit }); - } + }(); + _documentReady.fire({ + uploadingId, + options, + file, + thumb, + edit }); } else if (uploadingData.type() == SendMediaType::Secure) { _secureReady.fire({ uploadingId, diff --git a/Telegram/SourceFiles/storage/file_upload.h b/Telegram/SourceFiles/storage/file_upload.h index 462abe64e..89e4b4e77 100644 --- a/Telegram/SourceFiles/storage/file_upload.h +++ b/Telegram/SourceFiles/storage/file_upload.h @@ -39,14 +39,7 @@ struct UploadedDocument { FullMsgId fullId; Api::SendOptions options; MTPInputFile file; - bool edit = false; -}; - -struct UploadedThumbDocument { - FullMsgId fullId; - Api::SendOptions options; - MTPInputFile file; - MTPInputFile thumb; + std::optional thumb; bool edit = false; }; @@ -86,9 +79,6 @@ public: rpl::producer documentReady() const { return _documentReady.events(); } - rpl::producer thumbDocumentReady() const { - return _thumbDocumentReady.events(); - } rpl::producer secureReady() const { return _secureReady.events(); } @@ -148,7 +138,6 @@ private: rpl::event_stream _photoReady; rpl::event_stream _documentReady; - rpl::event_stream _thumbDocumentReady; rpl::event_stream _secureReady; rpl::event_stream _photoProgress; rpl::event_stream _documentProgress; diff --git a/Telegram/SourceFiles/window/themes/window_theme_editor_box.cpp b/Telegram/SourceFiles/window/themes/window_theme_editor_box.cpp index be67d6de3..bf927f7a0 100644 --- a/Telegram/SourceFiles/window/themes/window_theme_editor_box.cpp +++ b/Telegram/SourceFiles/window/themes/window_theme_editor_box.cpp @@ -489,7 +489,7 @@ Fn SavePreparedTheme( Fn fail) { Expects(window->account().sessionExists()); - using Storage::UploadedThumbDocument; + using Storage::UploadedDocument; struct State { FullMsgId id; bool generating = false; @@ -572,11 +572,11 @@ Fn SavePreparedTheme( }).send(); }; - const auto uploadTheme = [=](const UploadedThumbDocument &data) { + const auto uploadTheme = [=](const UploadedDocument &data) { state->requestId = api->request(MTPaccount_UploadTheme( MTP_flags(MTPaccount_UploadTheme::Flag::f_thumb), data.file, - data.thumb, + *data.thumb, MTP_string(state->filename), MTP_string("application/x-tgtheme-tdesktop") )).done([=](const MTPDocument &result) { @@ -598,10 +598,10 @@ Fn SavePreparedTheme( state->filename = media.filename; state->themeContent = theme; - session->uploader().thumbDocumentReady( - ) | rpl::filter([=](const UploadedThumbDocument &data) { - return data.fullId == state->id; - }) | rpl::start_with_next([=](const UploadedThumbDocument &data) { + session->uploader().documentReady( + ) | rpl::filter([=](const UploadedDocument &data) { + return (data.fullId == state->id) && data.thumb.has_value(); + }) | rpl::start_with_next([=](const UploadedDocument &data) { uploadTheme(data); }, state->lifetime);