diff --git a/Telegram/SourceFiles/info/media/info_media_list_widget.cpp b/Telegram/SourceFiles/info/media/info_media_list_widget.cpp index e3bcb5984e..3074318c9b 100644 --- a/Telegram/SourceFiles/info/media/info_media_list_widget.cpp +++ b/Telegram/SourceFiles/info/media/info_media_list_widget.cpp @@ -649,36 +649,41 @@ void ListWidget::restart() { } void ListWidget::itemRemoved(not_null item) { - if (isMyItem(item)) { - auto id = GetUniversalId(item); - - auto sectionIt = findSectionByItem(id); - if (sectionIt != _sections.end()) { - if (sectionIt->removeItem(id)) { - auto top = sectionIt->top(); - if (sectionIt->empty()) { - _sections.erase(sectionIt); - } - refreshHeight(); - } - } - - if (isItemLayout(item, _overLayout)) { - _overLayout = nullptr; - } - - if (const auto i = _layouts.find(id); i != _layouts.end()) { - _heavyLayouts.remove(i->second.item.get()); - _layouts.erase(i); - } - _dragSelected.remove(id); - - if (const auto i = _selected.find(id); i != _selected.cend()) { - removeItemSelection(i); - } - - mouseActionUpdate(_mousePosition); + if (!isMyItem(item)) { + return; } + auto id = GetUniversalId(item); + + auto needHeightRefresh = false; + auto sectionIt = findSectionByItem(id); + if (sectionIt != _sections.end()) { + if (sectionIt->removeItem(id)) { + auto top = sectionIt->top(); + if (sectionIt->empty()) { + _sections.erase(sectionIt); + } + needHeightRefresh = true; + } + } + + if (isItemLayout(item, _overLayout)) { + _overLayout = nullptr; + } + + if (const auto i = _layouts.find(id); i != _layouts.end()) { + _heavyLayouts.remove(i->second.item.get()); + _layouts.erase(i); + } + _dragSelected.remove(id); + + if (const auto i = _selected.find(id); i != _selected.cend()) { + removeItemSelection(i); + } + + if (needHeightRefresh) { + refreshHeight(); + } + mouseActionUpdate(_mousePosition); } FullMsgId ListWidget::computeFullId(