From 2c0a38d35632d4cdaaac69a2e15e6a79d5f63215 Mon Sep 17 00:00:00 2001 From: John Preston Date: Mon, 15 Aug 2022 15:40:11 +0300 Subject: [PATCH] Don't unload emoji sets. Fixes #24933. --- Telegram/SourceFiles/apiwrap.cpp | 8 ++++++-- Telegram/SourceFiles/boxes/add_contact_box.cpp | 6 +++--- Telegram/SourceFiles/boxes/send_files_box.cpp | 6 +++--- Telegram/SourceFiles/boxes/stickers_box.cpp | 5 ++++- .../SourceFiles/chat_helpers/stickers_list_widget.cpp | 7 ------- Telegram/SourceFiles/data/stickers/data_stickers.cpp | 6 ++++-- Telegram/SourceFiles/ui/boxes/rate_call_box.cpp | 2 +- 7 files changed, 21 insertions(+), 19 deletions(-) diff --git a/Telegram/SourceFiles/apiwrap.cpp b/Telegram/SourceFiles/apiwrap.cpp index ef0d5e9794..0e703dab83 100644 --- a/Telegram/SourceFiles/apiwrap.cpp +++ b/Telegram/SourceFiles/apiwrap.cpp @@ -1490,6 +1490,8 @@ void ApiWrap::saveStickerSets( if (!archived) { const auto featured = !!(set->flags & Flag::Featured); const auto special = !!(set->flags & Flag::Special); + const auto emoji = !!(set->flags & Flag::Emoji); + const auto locked = (set->locked > 0); const auto setId = set->mtpInput(); auto requestId = request(MTPmessages_UninstallStickerSet( @@ -1506,7 +1508,7 @@ void ApiWrap::saveStickerSets( if (removeIndex >= 0) { orderRef.removeAt(removeIndex); } - if (!featured && !special) { + if (!featured && !special && !emoji && !locked) { sets.erase(it); } else { if (archived) { @@ -1573,7 +1575,9 @@ void ApiWrap::saveStickerSets( if ((set->flags & Flag::Featured) || (set->flags & Flag::Installed) || (set->flags & Flag::Archived) - || (set->flags & Flag::Special)) { + || (set->flags & Flag::Special) + || (set->flags & Flag::Emoji) + || (set->locked > 0)) { ++it; } else { it = sets.erase(it); diff --git a/Telegram/SourceFiles/boxes/add_contact_box.cpp b/Telegram/SourceFiles/boxes/add_contact_box.cpp index 21fdff6469..4b9f93d163 100644 --- a/Telegram/SourceFiles/boxes/add_contact_box.cpp +++ b/Telegram/SourceFiles/boxes/add_contact_box.cpp @@ -897,10 +897,10 @@ void SetupChannelBox::prepare() { } void SetupChannelBox::setInnerFocus() { - if (_link->isHidden()) { - setFocus(); - } else { + if (!_link->isHidden()) { _link->setFocusFast(); + } else { + BoxContent::setInnerFocus(); } } diff --git a/Telegram/SourceFiles/boxes/send_files_box.cpp b/Telegram/SourceFiles/boxes/send_files_box.cpp index 5dbbc92cfd..8f14cd89b2 100644 --- a/Telegram/SourceFiles/boxes/send_files_box.cpp +++ b/Telegram/SourceFiles/boxes/send_files_box.cpp @@ -972,10 +972,10 @@ void SendFilesBox::updateControlsGeometry() { } void SendFilesBox::setInnerFocus() { - if (!_caption || _caption->isHidden()) { - setFocus(); - } else { + if (_caption && !_caption->isHidden()) { _caption->setFocusFast(); + } else { + BoxContent::setInnerFocus(); } } diff --git a/Telegram/SourceFiles/boxes/stickers_box.cpp b/Telegram/SourceFiles/boxes/stickers_box.cpp index f60a5f16f2..bc2b89bf71 100644 --- a/Telegram/SourceFiles/boxes/stickers_box.cpp +++ b/Telegram/SourceFiles/boxes/stickers_box.cpp @@ -1030,6 +1030,8 @@ void StickersBox::saveChanges() { void StickersBox::setInnerFocus() { if (_megagroupSet) { _installed.widget()->setInnerFocus(); + } else { + BoxContent::setInnerFocus(); } } @@ -1075,7 +1077,8 @@ StickersBox::Inner::Row::~Row() { const auto featured = !!(set->flags & SetFlag::Featured); const auto special = !!(set->flags & SetFlag::Special); const auto archived = !!(set->flags & SetFlag::Archived); - if (!installed && !featured && !special && !archived) { + const auto emoji = !!(set->flags & SetFlag::Emoji); + if (!installed && !featured && !special && !archived && !emoji) { auto &sets = set->owner().stickers().setsRef(); if (const auto i = sets.find(set->id); i != end(sets)) { sets.erase(i); diff --git a/Telegram/SourceFiles/chat_helpers/stickers_list_widget.cpp b/Telegram/SourceFiles/chat_helpers/stickers_list_widget.cpp index f0fa241afb..ead0369a97 100644 --- a/Telegram/SourceFiles/chat_helpers/stickers_list_widget.cpp +++ b/Telegram/SourceFiles/chat_helpers/stickers_list_widget.cpp @@ -2723,13 +2723,6 @@ object_ptr MakeConfirmRemoveSetBox( } set->flags &= ~SetFlag::Installed; set->installDate = TimeId(0); - // - // Set can be in search results. - // - //if (!(set->flags & SetFlag::Featured) - // && !(set->flags & SetFlag::Special)) { - // sets.erase(it); - //} auto &orderRef = (set->type() == Data::StickersType::Emoji) ? session->data().stickers().emojiSetsOrderRef() : (set->type() == Data::StickersType::Masks) diff --git a/Telegram/SourceFiles/data/stickers/data_stickers.cpp b/Telegram/SourceFiles/data/stickers/data_stickers.cpp index fe3fd2f458..c9f4749316 100644 --- a/Telegram/SourceFiles/data/stickers/data_stickers.cpp +++ b/Telegram/SourceFiles/data/stickers/data_stickers.cpp @@ -736,6 +736,7 @@ void Stickers::somethingReceived( const auto featured = !!(set->flags & SetFlag::Featured); const auto special = !!(set->flags & SetFlag::Special); const auto archived = !!(set->flags & SetFlag::Archived); + const auto emoji = !!(set->flags & SetFlag::Emoji); const auto locked = (set->locked > 0); if (!installed) { // remove not mine sets from recent stickers for (auto i = recent.begin(); i != recent.cend();) { @@ -747,7 +748,7 @@ void Stickers::somethingReceived( } } } - if (installed || featured || special || archived || locked) { + if (installed || featured || special || archived || emoji || locked) { ++it; } else { it = sets.erase(it); @@ -1062,8 +1063,9 @@ void Stickers::featuredReceived( const auto featured = (set->flags & SetFlag::Featured); const auto special = (set->flags & SetFlag::Special); const auto archived = (set->flags & SetFlag::Archived); + const auto emoji = !!(set->flags & SetFlag::Emoji); const auto locked = (set->locked > 0); - if (installed || featured || special || archived || locked) { + if (installed || featured || special || archived || emoji || locked) { if (featured && (set->flags & SetFlag::Unread)) { if (!(set->flags & SetFlag::Emoji)) { ++unreadCount; diff --git a/Telegram/SourceFiles/ui/boxes/rate_call_box.cpp b/Telegram/SourceFiles/ui/boxes/rate_call_box.cpp index f82994ff43..8d88bde67d 100644 --- a/Telegram/SourceFiles/ui/boxes/rate_call_box.cpp +++ b/Telegram/SourceFiles/ui/boxes/rate_call_box.cpp @@ -109,7 +109,7 @@ void RateCallBox::setInnerFocus() { if (_comment) { _comment->setFocusFast(); } else { - setFocus(); + BoxContent::setInnerFocus(); } }