mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +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 {
|
namespace Storage {
|
||||||
enum class MimeDataState;
|
enum class MimeDataState;
|
||||||
struct UploadedPhoto;
|
|
||||||
struct UploadedDocument;
|
|
||||||
struct UploadedThumbDocument;
|
|
||||||
} // namespace Storage
|
} // namespace Storage
|
||||||
|
|
||||||
namespace HistoryView {
|
namespace HistoryView {
|
||||||
|
|
|
@ -172,24 +172,6 @@ Uploader::Uploader(not_null<ApiWrap*> api)
|
||||||
|
|
||||||
documentReady(
|
documentReady(
|
||||||
) | rpl::start_with_next([=](const UploadedDocument &data) {
|
) | 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) {
|
if (data.edit) {
|
||||||
const auto item = session->data().message(data.fullId);
|
const auto item = session->data().message(data.fullId);
|
||||||
Api::EditMessageWithUploadedDocument(
|
Api::EditMessageWithUploadedDocument(
|
||||||
|
@ -206,7 +188,6 @@ Uploader::Uploader(not_null<ApiWrap*> api)
|
||||||
}
|
}
|
||||||
}, _lifetime);
|
}, _lifetime);
|
||||||
|
|
||||||
|
|
||||||
photoProgress(
|
photoProgress(
|
||||||
) | rpl::start_with_next([=](const FullMsgId &fullId) {
|
) | rpl::start_with_next([=](const FullMsgId &fullId) {
|
||||||
processPhotoProgress(fullId);
|
processPhotoProgress(fullId);
|
||||||
|
@ -500,31 +481,28 @@ void Uploader::sendNext() {
|
||||||
MTP_int(uploadingData.docPartsCount),
|
MTP_int(uploadingData.docPartsCount),
|
||||||
MTP_string(uploadingData.filename()),
|
MTP_string(uploadingData.filename()),
|
||||||
MTP_bytes(docMd5));
|
MTP_bytes(docMd5));
|
||||||
if (uploadingData.partsCount) {
|
const auto thumb = [&]() -> std::optional<MTPInputFile> {
|
||||||
|
if (!uploadingData.partsCount) {
|
||||||
|
return std::nullopt;
|
||||||
|
}
|
||||||
const auto thumbFilename = uploadingData.file
|
const auto thumbFilename = uploadingData.file
|
||||||
? uploadingData.file->thumbname
|
? uploadingData.file->thumbname
|
||||||
: (qsl("thumb.") + uploadingData.media.thumbExt);
|
: (qsl("thumb.") + uploadingData.media.thumbExt);
|
||||||
const auto thumbMd5 = uploadingData.file
|
const auto thumbMd5 = uploadingData.file
|
||||||
? uploadingData.file->thumbmd5
|
? uploadingData.file->thumbmd5
|
||||||
: uploadingData.media.jpeg_md5;
|
: uploadingData.media.jpeg_md5;
|
||||||
const auto thumb = MTP_inputFile(
|
return MTP_inputFile(
|
||||||
MTP_long(uploadingData.thumbId()),
|
MTP_long(uploadingData.thumbId()),
|
||||||
MTP_int(uploadingData.partsCount),
|
MTP_int(uploadingData.partsCount),
|
||||||
MTP_string(thumbFilename),
|
MTP_string(thumbFilename),
|
||||||
MTP_bytes(thumbMd5));
|
MTP_bytes(thumbMd5));
|
||||||
_thumbDocumentReady.fire({
|
}();
|
||||||
uploadingId,
|
_documentReady.fire({
|
||||||
options,
|
uploadingId,
|
||||||
file,
|
options,
|
||||||
thumb,
|
file,
|
||||||
edit });
|
thumb,
|
||||||
} else {
|
edit });
|
||||||
_documentReady.fire({
|
|
||||||
uploadingId,
|
|
||||||
options,
|
|
||||||
file,
|
|
||||||
edit });
|
|
||||||
}
|
|
||||||
} else if (uploadingData.type() == SendMediaType::Secure) {
|
} else if (uploadingData.type() == SendMediaType::Secure) {
|
||||||
_secureReady.fire({
|
_secureReady.fire({
|
||||||
uploadingId,
|
uploadingId,
|
||||||
|
|
|
@ -39,14 +39,7 @@ struct UploadedDocument {
|
||||||
FullMsgId fullId;
|
FullMsgId fullId;
|
||||||
Api::SendOptions options;
|
Api::SendOptions options;
|
||||||
MTPInputFile file;
|
MTPInputFile file;
|
||||||
bool edit = false;
|
std::optional<MTPInputFile> thumb;
|
||||||
};
|
|
||||||
|
|
||||||
struct UploadedThumbDocument {
|
|
||||||
FullMsgId fullId;
|
|
||||||
Api::SendOptions options;
|
|
||||||
MTPInputFile file;
|
|
||||||
MTPInputFile thumb;
|
|
||||||
bool edit = false;
|
bool edit = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -86,9 +79,6 @@ public:
|
||||||
rpl::producer<UploadedDocument> documentReady() const {
|
rpl::producer<UploadedDocument> documentReady() const {
|
||||||
return _documentReady.events();
|
return _documentReady.events();
|
||||||
}
|
}
|
||||||
rpl::producer<UploadedThumbDocument> thumbDocumentReady() const {
|
|
||||||
return _thumbDocumentReady.events();
|
|
||||||
}
|
|
||||||
rpl::producer<UploadSecureDone> secureReady() const {
|
rpl::producer<UploadSecureDone> secureReady() const {
|
||||||
return _secureReady.events();
|
return _secureReady.events();
|
||||||
}
|
}
|
||||||
|
@ -148,7 +138,6 @@ private:
|
||||||
|
|
||||||
rpl::event_stream<UploadedPhoto> _photoReady;
|
rpl::event_stream<UploadedPhoto> _photoReady;
|
||||||
rpl::event_stream<UploadedDocument> _documentReady;
|
rpl::event_stream<UploadedDocument> _documentReady;
|
||||||
rpl::event_stream<UploadedThumbDocument> _thumbDocumentReady;
|
|
||||||
rpl::event_stream<UploadSecureDone> _secureReady;
|
rpl::event_stream<UploadSecureDone> _secureReady;
|
||||||
rpl::event_stream<FullMsgId> _photoProgress;
|
rpl::event_stream<FullMsgId> _photoProgress;
|
||||||
rpl::event_stream<FullMsgId> _documentProgress;
|
rpl::event_stream<FullMsgId> _documentProgress;
|
||||||
|
|
|
@ -489,7 +489,7 @@ Fn<void()> SavePreparedTheme(
|
||||||
Fn<void(SaveErrorType,QString)> fail) {
|
Fn<void(SaveErrorType,QString)> fail) {
|
||||||
Expects(window->account().sessionExists());
|
Expects(window->account().sessionExists());
|
||||||
|
|
||||||
using Storage::UploadedThumbDocument;
|
using Storage::UploadedDocument;
|
||||||
struct State {
|
struct State {
|
||||||
FullMsgId id;
|
FullMsgId id;
|
||||||
bool generating = false;
|
bool generating = false;
|
||||||
|
@ -572,11 +572,11 @@ Fn<void()> SavePreparedTheme(
|
||||||
}).send();
|
}).send();
|
||||||
};
|
};
|
||||||
|
|
||||||
const auto uploadTheme = [=](const UploadedThumbDocument &data) {
|
const auto uploadTheme = [=](const UploadedDocument &data) {
|
||||||
state->requestId = api->request(MTPaccount_UploadTheme(
|
state->requestId = api->request(MTPaccount_UploadTheme(
|
||||||
MTP_flags(MTPaccount_UploadTheme::Flag::f_thumb),
|
MTP_flags(MTPaccount_UploadTheme::Flag::f_thumb),
|
||||||
data.file,
|
data.file,
|
||||||
data.thumb,
|
*data.thumb,
|
||||||
MTP_string(state->filename),
|
MTP_string(state->filename),
|
||||||
MTP_string("application/x-tgtheme-tdesktop")
|
MTP_string("application/x-tgtheme-tdesktop")
|
||||||
)).done([=](const MTPDocument &result) {
|
)).done([=](const MTPDocument &result) {
|
||||||
|
@ -598,10 +598,10 @@ Fn<void()> SavePreparedTheme(
|
||||||
state->filename = media.filename;
|
state->filename = media.filename;
|
||||||
state->themeContent = theme;
|
state->themeContent = theme;
|
||||||
|
|
||||||
session->uploader().thumbDocumentReady(
|
session->uploader().documentReady(
|
||||||
) | rpl::filter([=](const UploadedThumbDocument &data) {
|
) | rpl::filter([=](const UploadedDocument &data) {
|
||||||
return data.fullId == state->id;
|
return (data.fullId == state->id) && data.thumb.has_value();
|
||||||
}) | rpl::start_with_next([=](const UploadedThumbDocument &data) {
|
}) | rpl::start_with_next([=](const UploadedDocument &data) {
|
||||||
uploadTheme(data);
|
uploadTheme(data);
|
||||||
}, state->lifetime);
|
}, state->lifetime);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue