Fixed subscribeToUploader.

This commit is contained in:
23rd 2019-03-26 15:26:34 +03:00 committed by John Preston
parent aaf61dfbad
commit 1ed83cf193
8 changed files with 26 additions and 13 deletions

View File

@ -4483,7 +4483,9 @@ void ApiWrap::editMedia(
std::move(file.information),
type,
to,
caption));
caption,
nullptr,
true));
}
_fileLoader->addTasks(std::move(tasks));
}

View File

@ -4173,14 +4173,14 @@ void HistoryWidget::uploadFile(
Auth().api().sendFile(fileContent, type, options);
}
void HistoryWidget::subscribeToUploader(bool edit) {
void HistoryWidget::subscribeToUploader() {
if (_uploaderSubscriptions) {
return;
}
using namespace Storage;
Auth().uploader().photoReady(
) | rpl::start_with_next([=](const UploadedPhoto &data) {
edit
data.edit
? photoEdited(data.fullId, data.silent, data.file)
: photoUploaded(data.fullId, data.silent, data.file);
}, _uploaderSubscriptions);
@ -4194,7 +4194,7 @@ void HistoryWidget::subscribeToUploader(bool edit) {
}, _uploaderSubscriptions);
Auth().uploader().documentReady(
) | rpl::start_with_next([=](const UploadedDocument &data) {
edit
data.edit
? documentEdited(data.fullId, data.silent, data.file)
: documentUploaded(data.fullId, data.silent, data.file);
}, _uploaderSubscriptions);
@ -4236,9 +4236,8 @@ void HistoryWidget::sendFileConfirmed(
it->msgId = newId;
}
subscribeToUploader(isEditing);
subscribeToUploader();
file->edit = isEditing;
Auth().uploader().upload(newId, file);
const auto history = Auth().data().history(file->to.peer);

View File

@ -442,7 +442,7 @@ private:
MsgId replyTo,
std::shared_ptr<SendingAlbum> album = nullptr);
void subscribeToUploader(bool edit = false);
void subscribeToUploader();
void photoUploaded(
const FullMsgId &msgId,

View File

@ -1319,6 +1319,7 @@ void MainWidget::onEditMedia(
const std::shared_ptr<FileLoadResult> &file,
const FullMsgId &oldId) {
LOG(("ON EDIT MEDIA"));
App::main()->setEditMedia(FullMsgId());
_history->sendFileConfirmed(file, oldId);
}

View File

@ -329,7 +329,7 @@ void Uploader::sendNext() {
MTP_int(uploadingData.partsCount),
MTP_string(photoFilename),
MTP_bytes(md5));
_photoReady.fire({ uploadingId, silent, file });
_photoReady.fire({ uploadingId, silent, file, uploadingData.file->edit });
} else if (uploadingData.type() == SendMediaType::File
|| uploadingData.type() == SendMediaType::WallPaper
|| uploadingData.type() == SendMediaType::Audio) {
@ -364,7 +364,7 @@ void Uploader::sendNext() {
file,
thumb });
} else {
_documentReady.fire({ uploadingId, silent, file });
_documentReady.fire({ uploadingId, silent, file, uploadingData.file->edit });
}
} else if (uploadingData.type() == SendMediaType::Secure) {
_secureReady.fire({

View File

@ -19,12 +19,14 @@ struct UploadedPhoto {
FullMsgId fullId;
bool silent = false;
MTPInputFile file;
bool edit = false;
};
struct UploadedDocument {
FullMsgId fullId;
bool silent = false;
MTPInputFile file;
bool edit = false;
};
struct UploadedThumbDocument {
@ -32,6 +34,7 @@ struct UploadedThumbDocument {
bool silent = false;
MTPInputFile file;
MTPInputFile thumb;
bool edit = false;
};
struct UploadSecureProgress {

View File

@ -528,7 +528,8 @@ FileLoadTask::FileLoadTask(
SendMediaType type,
const FileLoadTo &to,
const TextWithTags &caption,
std::shared_ptr<SendingAlbum> album)
std::shared_ptr<SendingAlbum> album,
std::optional<bool> edit)
: _id(rand_value<uint64>())
, _to(to)
, _album(std::move(album))
@ -536,7 +537,8 @@ FileLoadTask::FileLoadTask(
, _content(content)
, _information(std::move(information))
, _type(type)
, _caption(caption) {
, _caption(caption)
, _edit(edit) {
}
FileLoadTask::FileLoadTask(
@ -697,6 +699,8 @@ void FileLoadTask::process() {
_caption,
_album);
_result->edit = _edit.value_or(false);
QString filename, filemime;
qint64 filesize = 0;
QByteArray filedata;

View File

@ -228,6 +228,8 @@ struct FileLoadResult {
PreparedPhotoThumbs photoThumbs;
TextWithTags caption;
bool edit = false;
void setFileData(const QByteArray &filedata);
void setThumbData(const QByteArray &thumbdata);
@ -273,7 +275,8 @@ public:
SendMediaType type,
const FileLoadTo &to,
const TextWithTags &caption,
std::shared_ptr<SendingAlbum> album = nullptr);
std::shared_ptr<SendingAlbum> album = nullptr,
std::optional<bool> edit = false);
FileLoadTask(
const QByteArray &voice,
int32 duration,
@ -320,6 +323,7 @@ private:
VoiceWaveform _waveform;
SendMediaType _type;
TextWithTags _caption;
std::optional<bool> _edit;
std::shared_ptr<FileLoadResult> _result;