feat: clear start token on right click

This commit is contained in:
AlexeyZavar 2024-08-10 10:42:09 +03:00
parent b15402dc72
commit 1e986f85d9

View file

@ -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());