mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-16 14:17:12 +02:00
Removed Storage::UploadedThumbDocument struct.
This commit is contained in:
parent
a6904be81d
commit
bc316a2536
4 changed files with 20 additions and 56 deletions
|
@ -89,9 +89,6 @@ class TabbedSelector;
|
|||
|
||||
namespace Storage {
|
||||
enum class MimeDataState;
|
||||
struct UploadedPhoto;
|
||||
struct UploadedDocument;
|
||||
struct UploadedThumbDocument;
|
||||
} // namespace Storage
|
||||
|
||||
namespace HistoryView {
|
||||
|
|
|
@ -172,24 +172,6 @@ Uploader::Uploader(not_null<ApiWrap*> 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<ApiWrap*> 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<MTPInputFile> {
|
||||
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,
|
||||
|
|
|
@ -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<MTPInputFile> thumb;
|
||||
bool edit = false;
|
||||
};
|
||||
|
||||
|
@ -86,9 +79,6 @@ public:
|
|||
rpl::producer<UploadedDocument> documentReady() const {
|
||||
return _documentReady.events();
|
||||
}
|
||||
rpl::producer<UploadedThumbDocument> thumbDocumentReady() const {
|
||||
return _thumbDocumentReady.events();
|
||||
}
|
||||
rpl::producer<UploadSecureDone> secureReady() const {
|
||||
return _secureReady.events();
|
||||
}
|
||||
|
@ -148,7 +138,6 @@ private:
|
|||
|
||||
rpl::event_stream<UploadedPhoto> _photoReady;
|
||||
rpl::event_stream<UploadedDocument> _documentReady;
|
||||
rpl::event_stream<UploadedThumbDocument> _thumbDocumentReady;
|
||||
rpl::event_stream<UploadSecureDone> _secureReady;
|
||||
rpl::event_stream<FullMsgId> _photoProgress;
|
||||
rpl::event_stream<FullMsgId> _documentProgress;
|
||||
|
|
|
@ -489,7 +489,7 @@ Fn<void()> SavePreparedTheme(
|
|||
Fn<void(SaveErrorType,QString)> fail) {
|
||||
Expects(window->account().sessionExists());
|
||||
|
||||
using Storage::UploadedThumbDocument;
|
||||
using Storage::UploadedDocument;
|
||||
struct State {
|
||||
FullMsgId id;
|
||||
bool generating = false;
|
||||
|
@ -572,11 +572,11 @@ Fn<void()> 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<void()> 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);
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue