From 590e6c8e9d14704606f8862056fceb82699e5e24 Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Mon, 1 Apr 2019 13:58:51 +0300 Subject: [PATCH] Fixed ability to cancel edit media in albums. --- Telegram/SourceFiles/data/data_groups.cpp | 8 +++++++- Telegram/SourceFiles/data/data_groups.h | 4 +++- Telegram/SourceFiles/history/history_message.cpp | 2 +- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/Telegram/SourceFiles/data/data_groups.cpp b/Telegram/SourceFiles/data/data_groups.cpp index f64ce5f84..763b1837e 100644 --- a/Telegram/SourceFiles/data/data_groups.cpp +++ b/Telegram/SourceFiles/data/data_groups.cpp @@ -64,7 +64,7 @@ void Groups::unregisterMessage(not_null item) { } } -void Groups::refreshMessage(not_null item) { +void Groups::refreshMessage(not_null item, bool forceRefresh) { if (!isGrouped(item)) { unregisterMessage(item); return; @@ -79,6 +79,12 @@ void Groups::refreshMessage(not_null 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)) { diff --git a/Telegram/SourceFiles/data/data_groups.h b/Telegram/SourceFiles/data/data_groups.h index 4e8d83fda..7eeed45cb 100644 --- a/Telegram/SourceFiles/data/data_groups.h +++ b/Telegram/SourceFiles/data/data_groups.h @@ -25,7 +25,9 @@ public: bool isGrouped(not_null item) const; void registerMessage(not_null item); void unregisterMessage(not_null item); - void refreshMessage(not_null item); + void refreshMessage( + not_null item, + bool forceRefresh = false); const Group *find(not_null item) const; diff --git a/Telegram/SourceFiles/history/history_message.cpp b/Telegram/SourceFiles/history/history_message.cpp index 227a9b84b..4a1c6d5bb 100644 --- a/Telegram/SourceFiles/history/history_message.cpp +++ b/Telegram/SourceFiles/history/history_message.cpp @@ -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); }