Fixed item updating when upload editing media.

This commit is contained in:
23rd 2019-03-26 18:56:33 +03:00 committed by John Preston
parent 1ed83cf193
commit f24ce584db
3 changed files with 13 additions and 1 deletions

View File

@ -122,6 +122,10 @@ public:
bool hasUnreadMediaFlag() const;
void markMediaRead();
void setIsEditingMedia(bool edit) {
_isEditingMedia = edit;
}
// Zero result means this message is not self-destructing right now.
virtual crl::time getSelfDestructIn(crl::time now) {
return 0;
@ -310,6 +314,7 @@ protected:
int _textWidth = -1;
int _textHeight = 0;
bool _isEditingMedia = false;
std::unique_ptr<Data::Media> _media;
private:

View File

@ -942,9 +942,11 @@ void HistoryMessage::updateSentMedia(const MTPMessageMedia *media) {
}
_flags &= ~MTPDmessage_ClientFlag::f_from_inline_bot;
} else {
if (!media || !_media || !_media->updateSentMedia(*media)) {
const auto shouldUpdate = _isEditingMedia ? true : !_media->updateSentMedia(*media);
if (!media || !_media || shouldUpdate) {
refreshSentMedia(media);
}
_isEditingMedia = false;
}
history()->owner().requestItemResize(this);
}

View File

@ -4290,6 +4290,11 @@ void HistoryWidget::sendFileConfirmed(
const auto messageType = isEditing
? NewMessageExisting
: NewMessageUnread;
if (isEditing) {
if (const auto itemToEdit = App::histItemById(newId)) {
itemToEdit->setIsEditingMedia(true);
}
}
if (file->type == SendMediaType::Photo) {
auto photoFlags = MTPDmessageMediaPhoto::Flag::f_photo | 0;
auto photo = MTP_messageMediaPhoto(