From 60c1ed6bb187dc4fe5c97ce9f8879232a9000a36 Mon Sep 17 00:00:00 2001 From: Sebastian Wolf Date: Fri, 7 Jan 2022 23:00:28 +0100 Subject: [PATCH] Try to optimize sticker set handling (less reload) --- qml/pages/ChatPage.qml | 4 ++-- src/stickermanager.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/qml/pages/ChatPage.qml b/qml/pages/ChatPage.qml index c1eda12..a4af816 100644 --- a/qml/pages/ChatPage.qml +++ b/qml/pages/ChatPage.qml @@ -178,9 +178,8 @@ Page { updateGroupStatusText(); } if (stickerManager.needsReload()) { - Debug.log("[ChatPage] Stickers will be reloaded!"); + Debug.log("[ChatPage] Recent stickers will be reloaded!"); tdLibWrapper.getRecentStickers(); - tdLibWrapper.getInstalledStickerSets(); stickerManager.setNeedsReload(false); } tdLibWrapper.getChatPinnedMessage(chatInformation.id); @@ -1448,6 +1447,7 @@ Page { target: stickerPickerLoader.item onStickerPicked: { Debug.log("Sticker picked: " + stickerId); + stickerManager.setNeedsReload(true); tdLibWrapper.sendStickerMessage(chatInformation.id, stickerId, newMessageColumn.replyToMessageId); stickerPickerLoader.active = false; attachmentOptionsFlickable.isNeeded = false; diff --git a/src/stickermanager.cpp b/src/stickermanager.cpp index 6019e7d..509490e 100644 --- a/src/stickermanager.cpp +++ b/src/stickermanager.cpp @@ -27,6 +27,7 @@ StickerManager::StickerManager(TDLibWrapper *tdLibWrapper, QObject *parent) : QO { LOG("Initializing..."); this->tdLibWrapper = tdLibWrapper; + this->reloadNeeded = false; connect(this->tdLibWrapper, SIGNAL(recentStickersUpdated(QVariantList)), this, SLOT(handleRecentStickersUpdated(QVariantList))); connect(this->tdLibWrapper, SIGNAL(stickersReceived(QVariantList)), this, SLOT(handleStickersReceived(QVariantList))); @@ -157,7 +158,6 @@ void StickerManager::handleStickerSetReceived(const QVariantMap &stickerSet) QVariantMap thumbnailLocalFile = thumbnailFile.value("local").toMap(); if (!thumbnailLocalFile.value("is_downloading_completed").toBool()) { tdLibWrapper->downloadFile(thumbnailFile.value("id").toInt()); - this->reloadNeeded = true; } } }