Fixed ability to cancel edit media in albums.

This commit is contained in:
23rd 2019-04-01 13:58:51 +03:00 committed by John Preston
parent 67572b0d9a
commit 590e6c8e9d
3 changed files with 11 additions and 3 deletions

View File

@ -64,7 +64,7 @@ void Groups::unregisterMessage(not_null<const HistoryItem*> item) {
}
}
void Groups::refreshMessage(not_null<HistoryItem*> item) {
void Groups::refreshMessage(not_null<HistoryItem*> item, bool forceRefresh) {
if (!isGrouped(item)) {
unregisterMessage(item);
return;
@ -79,6 +79,12 @@ void Groups::refreshMessage(not_null<HistoryItem*> item) {
return;
}
auto &items = i->second.items;
if (forceRefresh) {
refreshViews(items);
return;
}
const auto position = findPositionForItem(items, item);
auto current = ranges::find(items, item);
if (current == end(items)) {

View File

@ -25,7 +25,9 @@ public:
bool isGrouped(not_null<HistoryItem*> item) const;
void registerMessage(not_null<HistoryItem*> item);
void unregisterMessage(not_null<const HistoryItem*> item);
void refreshMessage(not_null<HistoryItem*> item);
void refreshMessage(
not_null<HistoryItem*> item,
bool forceRefresh = false);
const Group *find(not_null<HistoryItem*> item) const;

View File

@ -765,7 +765,7 @@ void HistoryMessage::returnSavedMedia() {
const auto wasGrouped = history()->owner().groups().isGrouped(this);
_media = std::move(_savedMedia);
if (wasGrouped) {
history()->owner().groups().refreshMessage(this);
history()->owner().groups().refreshMessage(this, true);
} else {
history()->owner().requestItemViewRefresh(this);
}