mirror of https://github.com/procxx/kepka.git
Added handler for MESSAGE_NOT_MODIFIED error when edit media.
This commit is contained in:
parent
653fd1bb63
commit
0e4d85a5e5
|
@ -4640,8 +4640,17 @@ void ApiWrap::editUploadedPhoto(
|
||||||
media,
|
media,
|
||||||
MTPReplyMarkup(),
|
MTPReplyMarkup(),
|
||||||
sentEntities
|
sentEntities
|
||||||
)).done([=](const MTPUpdates &result) { LOG(("APPLY.")); applyUpdates(result);
|
)).done([=](const MTPUpdates &result) {
|
||||||
}).fail([=](const RPCError &error) { LOG(("FAIL."));
|
item->clearSavedMedia();
|
||||||
|
applyUpdates(result);
|
||||||
|
}).fail([=](const RPCError &error) {
|
||||||
|
QString err = error.type();
|
||||||
|
if (err == qstr("MESSAGE_NOT_MODIFIED")) {
|
||||||
|
item->returnSavedMedia();
|
||||||
|
_session->data().sendHistoryChangeNotifications();
|
||||||
|
} else {
|
||||||
|
sendMessageFail(error);
|
||||||
|
}
|
||||||
}).send();
|
}).send();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4694,8 +4703,17 @@ void ApiWrap::editUploadedDocument(
|
||||||
media,
|
media,
|
||||||
MTPReplyMarkup(),
|
MTPReplyMarkup(),
|
||||||
sentEntities
|
sentEntities
|
||||||
)).done([=](const MTPUpdates &result) { LOG(("APPLY.")); applyUpdates(result);
|
)).done([=](const MTPUpdates &result) {
|
||||||
}).fail([=](const RPCError &error) { LOG(("FAIL."));
|
item->clearSavedMedia();
|
||||||
|
applyUpdates(result);
|
||||||
|
}).fail([=](const RPCError &error) {
|
||||||
|
QString err = error.type();
|
||||||
|
if (err == qstr("MESSAGE_NOT_MODIFIED")) {
|
||||||
|
item->returnSavedMedia();
|
||||||
|
_session->data().sendHistoryChangeNotifications();
|
||||||
|
} else {
|
||||||
|
sendMessageFail(error);
|
||||||
|
}
|
||||||
}).send();
|
}).send();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -132,6 +132,7 @@ public:
|
||||||
|
|
||||||
// For edit media in history_message.
|
// For edit media in history_message.
|
||||||
virtual void returnSavedMedia() {};
|
virtual void returnSavedMedia() {};
|
||||||
|
virtual void clearSavedMedia() {};
|
||||||
|
|
||||||
// Zero result means this message is not self-destructing right now.
|
// Zero result means this message is not self-destructing right now.
|
||||||
virtual crl::time getSelfDestructIn(crl::time now) {
|
virtual crl::time getSelfDestructIn(crl::time now) {
|
||||||
|
|
|
@ -742,7 +742,6 @@ QString FormatViewsCount(int views) {
|
||||||
|
|
||||||
void HistoryMessage::refreshMedia(const MTPMessageMedia *media) {
|
void HistoryMessage::refreshMedia(const MTPMessageMedia *media) {
|
||||||
_media = nullptr;
|
_media = nullptr;
|
||||||
_savedMedia = nullptr;
|
|
||||||
if (media) {
|
if (media) {
|
||||||
setMedia(*media);
|
setMedia(*media);
|
||||||
}
|
}
|
||||||
|
|
|
@ -90,6 +90,9 @@ public:
|
||||||
void refreshMedia(const MTPMessageMedia *media);
|
void refreshMedia(const MTPMessageMedia *media);
|
||||||
void refreshSentMedia(const MTPMessageMedia *media);
|
void refreshSentMedia(const MTPMessageMedia *media);
|
||||||
void returnSavedMedia() override;
|
void returnSavedMedia() override;
|
||||||
|
void clearSavedMedia() {
|
||||||
|
_savedMedia = nullptr;
|
||||||
|
}
|
||||||
void setMedia(const MTPMessageMedia &media);
|
void setMedia(const MTPMessageMedia &media);
|
||||||
static std::unique_ptr<Data::Media> CreateMedia(
|
static std::unique_ptr<Data::Media> CreateMedia(
|
||||||
not_null<HistoryMessage*> item,
|
not_null<HistoryMessage*> item,
|
||||||
|
|
Loading…
Reference in New Issue