From c40f63911c1fad5ea5a18894f530892ddb87c8ea Mon Sep 17 00:00:00 2001 From: Alexander Gavriliuk Date: Fri, 22 Sep 2023 01:19:42 +0200 Subject: SL-20294 The row of recent emojis displays the recently sent emoji only after clicking the collapsing smiley button --- indra/newview/llfloateremojipicker.cpp | 12 +++++ indra/newview/llfloateremojipicker.h | 1 + indra/newview/llfloaterimsessiontab.cpp | 82 ++++++++++++++++++++------------- indra/newview/llfloaterimsessiontab.h | 2 +- 4 files changed, 64 insertions(+), 33 deletions(-) diff --git a/indra/newview/llfloateremojipicker.cpp b/indra/newview/llfloateremojipicker.cpp index 1608a4f19c..10013c907d 100644 --- a/indra/newview/llfloateremojipicker.cpp +++ b/indra/newview/llfloateremojipicker.cpp @@ -771,6 +771,18 @@ void LLFloaterEmojiPicker::onEmojiUsed(llwchar emoji) sFrequentlyUsed.push_back(std::make_pair(emoji, 1)); } +// static +void LLFloaterEmojiPicker::onRecentlyUsedChanged() +{ + if (sSelectedGroupIndex) + return; + + if (LLFloaterEmojiPicker* picker = getInstance()) + { + picker->fillEmojis(); + } +} + // static void LLFloaterEmojiPicker::loadState() { diff --git a/indra/newview/llfloateremojipicker.h b/indra/newview/llfloateremojipicker.h index cfb3da3acc..b8e3190bf3 100644 --- a/indra/newview/llfloateremojipicker.h +++ b/indra/newview/llfloateremojipicker.h @@ -56,6 +56,7 @@ public: static std::list& getRecentlyUsed(); static void onEmojiUsed(llwchar emoji); + static void onRecentlyUsedChanged(); static void loadState(); static void saveState(); diff --git a/indra/newview/llfloaterimsessiontab.cpp b/indra/newview/llfloaterimsessiontab.cpp index d46780fa81..7a0de78ac5 100644 --- a/indra/newview/llfloaterimsessiontab.cpp +++ b/indra/newview/llfloaterimsessiontab.cpp @@ -456,7 +456,7 @@ void LLFloaterIMSessionTab::onEmojiRecentPanelToggleBtnClicked(LLFloaterIMSessio BOOL show = !self->mEmojiRecentPanel->getVisible(); if (show) { - self->onEmojiRecentPanelOpening(); + self->initEmojiRecentPanel(true); } self->mEmojiRecentPanel->setVisible(show); } @@ -482,27 +482,33 @@ void LLFloaterIMSessionTab::onEmojiPickerToggleBtnClicked(LLFloaterIMSessionTab* } } -void LLFloaterIMSessionTab::onEmojiRecentPanelOpening() -{ - std::list& recentlyUsed = LLFloaterEmojiPicker::getRecentlyUsed(); - if (recentlyUsed.empty()) - { - mEmojiRecentEmptyText->setVisible(true); - mEmojiRecentIconsCtrl->setVisible(false); - mEmojiPickerToggleBtn->setFocus(true); - } - else - { - LLWString emojis; - for (llwchar emoji : recentlyUsed) - { - emojis += emoji; - } - mEmojiRecentIconsCtrl->setEmojis(emojis); - mEmojiRecentEmptyText->setVisible(false); - mEmojiRecentIconsCtrl->setVisible(true); - mEmojiRecentIconsCtrl->setFocus(true); - } +void LLFloaterIMSessionTab::initEmojiRecentPanel(bool moveFocus) +{ + std::list& recentlyUsed = LLFloaterEmojiPicker::getRecentlyUsed(); + if (recentlyUsed.empty()) + { + mEmojiRecentEmptyText->setVisible(true); + mEmojiRecentIconsCtrl->setVisible(false); + if (moveFocus) + { + mEmojiPickerToggleBtn->setFocus(true); + } + } + else + { + LLWString emojis; + for (llwchar emoji : recentlyUsed) + { + emojis += emoji; + } + mEmojiRecentIconsCtrl->setEmojis(emojis); + mEmojiRecentEmptyText->setVisible(false); + mEmojiRecentIconsCtrl->setVisible(true); + if (moveFocus) + { + mEmojiRecentIconsCtrl->setFocus(true); + } + } } void LLFloaterIMSessionTab::onRecentEmojiPicked(const LLSD& value) @@ -514,7 +520,7 @@ void LLFloaterIMSessionTab::onRecentEmojiPicked(const LLSD& value) if (wstr.size()) { llwchar emoji = wstr[0]; - onEmojiPicked(emoji); + mInputEditor->insertEmoji(emoji); } } } @@ -579,16 +585,28 @@ void LLFloaterIMSessionTab::appendMessage(const LLChat& chat, const LLSD& args) void LLFloaterIMSessionTab::updateUsedEmojis(LLWString text) { - LLEmojiDictionary* dictionary = LLEmojiDictionary::getInstance(); - llassert_always(dictionary); + LLEmojiDictionary* dictionary = LLEmojiDictionary::getInstance(); + llassert_always(dictionary); - for (llwchar& c : text) - { - if (dictionary->isEmoji(c)) - { - LLFloaterEmojiPicker::onEmojiUsed(c); - } - } + bool emojiSent = false; + for (llwchar& c : text) + { + if (dictionary->isEmoji(c)) + { + LLFloaterEmojiPicker::onEmojiUsed(c); + emojiSent = true; + } + } + + if (!emojiSent) + return; + + LLFloaterEmojiPicker::onRecentlyUsedChanged(); + + if (mEmojiRecentPanel->getVisible()) + { + initEmojiRecentPanel(false); + } } static LLTrace::BlockTimerStatHandle FTM_BUILD_CONVERSATION_VIEW_PARTICIPANT("Build Conversation View"); diff --git a/indra/newview/llfloaterimsessiontab.h b/indra/newview/llfloaterimsessiontab.h index d21f611172..0ff3d0b38c 100644 --- a/indra/newview/llfloaterimsessiontab.h +++ b/indra/newview/llfloaterimsessiontab.h @@ -217,7 +217,7 @@ private: static void onEmojiRecentPanelToggleBtnClicked(LLFloaterIMSessionTab* self); static void onEmojiPickerToggleBtnClicked(LLFloaterIMSessionTab* self); - void onEmojiRecentPanelOpening(); + void initEmojiRecentPanel(bool moveFocus); void onRecentEmojiPicked(const LLSD& value); void onEmojiPicked(llwchar emoji); void onEmojiPickerClosed(); -- cgit v1.2.3