diff --git a/Telegram/SourceFiles/mainwidget.cpp b/Telegram/SourceFiles/mainwidget.cpp index c73b70bd6..c87515042 100644 --- a/Telegram/SourceFiles/mainwidget.cpp +++ b/Telegram/SourceFiles/mainwidget.cpp @@ -94,6 +94,16 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include #include +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 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 ¶ms) { } 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) { diff --git a/Telegram/SourceFiles/mainwidget.h b/Telegram/SourceFiles/mainwidget.h index 12ef1359c..6680cff57 100644 --- a/Telegram/SourceFiles/mainwidget.h +++ b/Telegram/SourceFiles/mainwidget.h @@ -173,8 +173,6 @@ public: void checkChatBackground(); Image *newBackgroundThumb(); - void clearBotStartToken(PeerData *peer); - void setInnerFocus(); bool contentOverlapped(const QRect &globalRect);