diff --git a/Telegram/SourceFiles/history/history.style b/Telegram/SourceFiles/history/history.style index d9328ff7bf..df2c081772 100644 --- a/Telegram/SourceFiles/history/history.style +++ b/Telegram/SourceFiles/history/history.style @@ -382,6 +382,7 @@ historyDateFadeDuration: 200; historyDiceToast: Toast(defaultToast) { minWidth: msgMinWidth; maxWidth: 640px; + durationFadeOut: 200; } historyErrorToast: Toast(defaultToast) { minWidth: msgMinWidth; diff --git a/Telegram/SourceFiles/history/view/media/history_view_dice.cpp b/Telegram/SourceFiles/history/view/media/history_view_dice.cpp index 4db8eec9c6..8a438534e5 100644 --- a/Telegram/SourceFiles/history/view/media/history_view_dice.cpp +++ b/Telegram/SourceFiles/history/view/media/history_view_dice.cpp @@ -35,6 +35,13 @@ namespace { [[nodiscard]] ClickHandlerPtr MakeDiceHandler( not_null history, const QString &emoji) { + static auto ShownToast = base::weak_ptr(); + static const auto HideExisting = [] { + if (const auto toast = ShownToast.get()) { + toast->hideAnimated(); + ShownToast = nullptr; + } + }; return std::make_shared([=] { auto config = Ui::Toast::Config{ .text = { tr::lng_about_random(tr::now, lt_emoji, emoji) }, @@ -51,16 +58,20 @@ namespace { config.filter = crl::guard(&history->session(), [=]( const ClickHandlerPtr &handler, Qt::MouseButton button) { - if (button == Qt::LeftButton) { + if (button == Qt::LeftButton && !ShownToast.empty()) { auto message = Api::MessageToSend(history); message.action.clearDraft = false; message.textWithTags.text = emoji; + Api::SendDice(message); + HideExisting(); } return false; }); } - Ui::Toast::Show(config); + + HideExisting(); + ShownToast = Ui::Toast::Show(config); }); }