2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-31 06:26:18 +00:00

Moved out MainWidget::clearBotStartToken to static function.

This commit is contained in:
23rd
2024-08-28 09:49:53 +03:00
parent 920484d540
commit ed667a42ad
2 changed files with 18 additions and 14 deletions

View File

@@ -94,6 +94,16 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include <QtCore/QCoreApplication>
#include <QtCore/QMimeData>
namespace {
void ClearBotStartToken(PeerData *peer) {
if (peer && peer->isUser() && peer->asUser()->isBot()) {
peer->asUser()->botInfo->startToken = QString();
}
}
} // namespace
enum StackItemType {
HistoryStackItem,
SectionStackItem,
@@ -1205,12 +1215,6 @@ void MainWidget::setInnerFocus() {
}
}
void MainWidget::clearBotStartToken(PeerData *peer) {
if (peer && peer->isUser() && peer->asUser()->isBot()) {
peer->asUser()->botInfo->startToken = QString();
}
}
void MainWidget::showChooseReportMessages(
not_null<PeerData*> peer,
Ui::ReportReason reason,
@@ -1290,7 +1294,9 @@ void MainWidget::showHistory(
if (peer->migrateTo()) {
peer = peer->migrateTo();
peerId = peer->id;
if (showAtMsgId > 0) showAtMsgId = -showAtMsgId;
if (showAtMsgId > 0) {
showAtMsgId = -showAtMsgId;
}
}
const auto unavailable = peer->computeUnavailableReason();
if (!unavailable.isEmpty()) {
@@ -1345,7 +1351,7 @@ void MainWidget::showHistory(
bool foundInStack = !peerId;
if (foundInStack || (way == Way::ClearStack)) {
for (const auto &item : _stack) {
clearBotStartToken(item->peer());
ClearBotStartToken(item->peer());
}
_stack.clear();
} else {
@@ -1353,7 +1359,7 @@ void MainWidget::showHistory(
if (_stack.at(i)->type() == HistoryStackItem && _stack.at(i)->peer()->id == peerId) {
foundInStack = true;
while (int(_stack.size()) > i + 1) {
clearBotStartToken(_stack.back()->peer());
ClearBotStartToken(_stack.back()->peer());
_stack.pop_back();
}
_stack.pop_back();
@@ -1415,7 +1421,7 @@ void MainWidget::showHistory(
if (_history->peer()
&& _history->peer()->id != peerId
&& way != Way::Forward) {
clearBotStartToken(_history->peer());
ClearBotStartToken(_history->peer());
}
_history->showHistory(
peerId,
@@ -1981,8 +1987,8 @@ bool MainWidget::showBackFromStack(const SectionShow &params) {
}
auto item = std::move(_stack.back());
_stack.pop_back();
if (auto currentHistoryPeer = _history->peer()) {
clearBotStartToken(currentHistoryPeer);
if (const auto currentHistoryPeer = _history->peer()) {
ClearBotStartToken(currentHistoryPeer);
}
_thirdSectionFromStack = item->takeThirdSectionMemento();
if (item->type() == HistoryStackItem) {