2
0
mirror of https://github.com/kotatogram/kotatogram-desktop synced 2025-08-31 14:45:14 +00:00

Added initial implementation of cancel of media uploading for editing.

This commit is contained in:
23rd
2019-03-29 17:17:46 +03:00
committed by John Preston
parent 741501d1d9
commit 653fd1bb63
4 changed files with 35 additions and 4 deletions

View File

@@ -742,6 +742,7 @@ QString FormatViewsCount(int views) {
void HistoryMessage::refreshMedia(const MTPMessageMedia *media) {
_media = nullptr;
_savedMedia = nullptr;
if (media) {
setMedia(*media);
}
@@ -757,6 +758,19 @@ void HistoryMessage::refreshSentMedia(const MTPMessageMedia *media) {
}
}
void HistoryMessage::returnSavedMedia() {
if (!_savedMedia) {
return;
}
const auto wasGrouped = history()->owner().groups().isGrouped(this);
_media = std::move(_savedMedia);
if (wasGrouped) {
history()->owner().groups().refreshMessage(this);
} else {
history()->owner().requestItemViewRefresh(this);
}
}
void HistoryMessage::setMedia(const MTPMessageMedia &media) {
_media = CreateMedia(this, media);
if (const auto invoice = _media ? _media->invoice() : nullptr) {
@@ -943,10 +957,13 @@ void HistoryMessage::updateSentMedia(const MTPMessageMedia *media) {
_flags &= ~MTPDmessage_ClientFlag::f_from_inline_bot;
} else {
const auto shouldUpdate = _isEditingMedia ? true : !_media->updateSentMedia(*media);
if (_isEditingMedia) {
_savedMedia = _media->clone(this);
}
if (!media || !_media || shouldUpdate) {
refreshSentMedia(media);
}
_isEditingMedia = false;
// _isEditingMedia = false;
}
history()->owner().requestItemResize(this);
}