From 1e986f85d932b7a09ee9001cde9bd5d41b46866d Mon Sep 17 00:00:00 2001 From: AlexeyZavar Date: Sat, 10 Aug 2024 10:42:09 +0300 Subject: [PATCH] feat: clear start token on right click --- .../SourceFiles/history/history_widget.cpp | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/Telegram/SourceFiles/history/history_widget.cpp b/Telegram/SourceFiles/history/history_widget.cpp index 853d90119..1d1950fdf 100644 --- a/Telegram/SourceFiles/history/history_widget.cpp +++ b/Telegram/SourceFiles/history/history_widget.cpp @@ -353,7 +353,20 @@ HistoryWidget::HistoryWidget( sendAction); } _unblock->addClickHandler([=] { unblockUser(); }); - _botStart->addClickHandler([=] { sendBotStartCommand(); }); + _botStart->setAcceptBoth(true); + _botStart->clicks() | rpl::start_with_next( + [=](Qt::MouseButton button) + { + if (button == Qt::LeftButton) { + sendBotStartCommand(); + } else if (button == Qt::RightButton && isBotStart() && !_peer->asUser()->botInfo->startToken.isEmpty()) { + _peer->asUser()->botInfo->startToken = QString(); + session().changes().peerUpdated( + _peer, + Data::PeerUpdate::Flag::BotStartToken); + } + }, + _botStart->lifetime()); _joinChannel->addClickHandler([=] { joinChannel(); }); _muteUnmute->addClickHandler([=] { toggleMuteUnmute(); }); _discuss->addClickHandler([=] { goToDiscussionGroup(); }); @@ -3027,7 +3040,8 @@ void HistoryWidget::updateControlsVisibility() { const auto startToken = _peer->asUser()->botInfo->startToken; if (!startToken.isEmpty()) { - const auto s = QString("%1 (%2)").arg(tr::lng_bot_start(tr::now).toUpper()).arg(startToken); + const auto shortened = startToken.left(20); + const auto s = QString("%1 (%2)").arg(tr::lng_bot_start(tr::now).toUpper()).arg(shortened); _botStart->setText(s); } else { _botStart->setText(tr::lng_bot_start(tr::now).toUpper());