diff --git a/Telegram/SourceFiles/api/api_earn.cpp b/Telegram/SourceFiles/api/api_earn.cpp index 14615514b..c44690151 100644 --- a/Telegram/SourceFiles/api/api_earn.cpp +++ b/Telegram/SourceFiles/api/api_earn.cpp @@ -40,6 +40,7 @@ void HandleWithdrawalButton( std::shared_ptr show) { Expects(receiver.currencyReceiver || (receiver.creditsReceiver && receiver.creditsAmount)); + struct State { rpl::lifetime lifetime; bool loading = false; @@ -58,8 +59,7 @@ void HandleWithdrawalButton( const auto processOut = [=] { if (state->loading) { return; - } - if (peer && !receiver.creditsAmount()) { + } else if (peer && !receiver.creditsAmount()) { return; } state->loading = true; diff --git a/Telegram/SourceFiles/boxes/local_storage_box.cpp b/Telegram/SourceFiles/boxes/local_storage_box.cpp index fcdbd8d6d..647d6e0e9 100644 --- a/Telegram/SourceFiles/boxes/local_storage_box.cpp +++ b/Telegram/SourceFiles/boxes/local_storage_box.cpp @@ -240,7 +240,8 @@ int LocalStorageBox::Row::resizeGetHeight(int newWidth) { } void LocalStorageBox::Row::paintEvent(QPaintEvent *e) { - if (!_progress || true) { +#if 0 // not used + if (!_progress) { return; } auto p = QPainter(this); @@ -254,6 +255,7 @@ void LocalStorageBox::Row::paintEvent(QPaintEvent *e) { st::proxyCheckingPosition.y() + bottom }, width()); +#endif } QString LocalStorageBox::Row::titleText(const Database::TaggedSummary &data) const { diff --git a/Telegram/SourceFiles/chat_helpers/stickers_list_footer.cpp b/Telegram/SourceFiles/chat_helpers/stickers_list_footer.cpp index 8d666249f..237865424 100644 --- a/Telegram/SourceFiles/chat_helpers/stickers_list_footer.cpp +++ b/Telegram/SourceFiles/chat_helpers/stickers_list_footer.cpp @@ -822,7 +822,7 @@ void StickersListFooter::mousePressEvent(QMouseEvent *e) { if (e->button() != Qt::LeftButton) { return; } - _iconsMousePos = e ? e->globalPos() : QCursor::pos(); + _iconsMousePos = e->globalPos(); updateSelected(); if (_selected == SpecialOver::Settings) { diff --git a/Telegram/SourceFiles/chat_helpers/stickers_lottie.cpp b/Telegram/SourceFiles/chat_helpers/stickers_lottie.cpp index 095abbb57..9c830dc57 100644 --- a/Telegram/SourceFiles/chat_helpers/stickers_lottie.cpp +++ b/Telegram/SourceFiles/chat_helpers/stickers_lottie.cpp @@ -192,9 +192,7 @@ std::unique_ptr LottieThumbnail( }; const auto session = thumb ? &thumb->owner()->session() - : media - ? &media->owner()->session() - : nullptr; + : &media->owner()->session(); return LottieCachedFromContent( method, baseKey, diff --git a/Telegram/SourceFiles/core/click_handler_types.cpp b/Telegram/SourceFiles/core/click_handler_types.cpp index 231d01972..ded39a2f8 100644 --- a/Telegram/SourceFiles/core/click_handler_types.cpp +++ b/Telegram/SourceFiles/core/click_handler_types.cpp @@ -189,6 +189,7 @@ void BotGameUrlClickHandler::onClick(ClickContext context) const { const auto game = media ? media->game() : nullptr; if (url.startsWith(u"tg://"_q, Qt::CaseInsensitive) || !_bot || !game) { openLink(); + return; } const auto bot = _bot; const auto title = game->title; diff --git a/Telegram/SourceFiles/data/components/recent_peers.cpp b/Telegram/SourceFiles/data/components/recent_peers.cpp index 0917be2b9..6b49ea759 100644 --- a/Telegram/SourceFiles/data/components/recent_peers.cpp +++ b/Telegram/SourceFiles/data/components/recent_peers.cpp @@ -126,7 +126,6 @@ void RecentPeers::applyLocal(QByteArray serialized) { ).arg(count)); DEBUG_LOG(("Failed bytes: %1.").arg( QString::fromUtf8(serialized.mid(streamPosition).toHex()))); - _list.clear(); return; } } diff --git a/Telegram/SourceFiles/data/stickers/data_stickers.cpp b/Telegram/SourceFiles/data/stickers/data_stickers.cpp index 4133af7b6..d04b880a6 100644 --- a/Telegram/SourceFiles/data/stickers/data_stickers.cpp +++ b/Telegram/SourceFiles/data/stickers/data_stickers.cpp @@ -206,22 +206,20 @@ void Stickers::incrementSticker(not_null document) { auto &sets = setsRef(); auto it = sets.find(Data::Stickers::CloudRecentSetId); if (it == sets.cend()) { - if (it == sets.cend()) { - it = sets.emplace( + it = sets.emplace( + Data::Stickers::CloudRecentSetId, + std::make_unique( + &session().data(), Data::Stickers::CloudRecentSetId, - std::make_unique( - &session().data(), - Data::Stickers::CloudRecentSetId, - uint64(0), // accessHash - uint64(0), // hash - tr::lng_recent_stickers(tr::now), - QString(), - 0, // count - SetFlag::Special, - TimeId(0))).first; - } else { - it->second->title = tr::lng_recent_stickers(tr::now); - } + uint64(0), // accessHash + uint64(0), // hash + tr::lng_recent_stickers(tr::now), + QString(), + 0, // count + SetFlag::Special, + TimeId(0))).first; + } else { + it->second->title = tr::lng_recent_stickers(tr::now); } const auto set = it->second.get(); auto removedFromEmoji = std::vector>(); diff --git a/Telegram/SourceFiles/export/export_api_wrap.cpp b/Telegram/SourceFiles/export/export_api_wrap.cpp index b511b9fe3..fe2cd8bea 100644 --- a/Telegram/SourceFiles/export/export_api_wrap.cpp +++ b/Telegram/SourceFiles/export/export_api_wrap.cpp @@ -438,8 +438,6 @@ void ApiWrap::startExport( } if (_settings->types & Settings::Type::AnyChatsMask) { _startProcess->steps.push_back(Step::SplitRanges); - } - if (_settings->types & Settings::Type::AnyChatsMask) { _startProcess->steps.push_back(Step::DialogsCount); } if (_settings->types & Settings::Type::GroupsChannelsMask) { diff --git a/Telegram/SourceFiles/history/history_widget.cpp b/Telegram/SourceFiles/history/history_widget.cpp index 7caf21053..33eec2d34 100644 --- a/Telegram/SourceFiles/history/history_widget.cpp +++ b/Telegram/SourceFiles/history/history_widget.cpp @@ -869,7 +869,7 @@ HistoryWidget::HistoryWidget( } if (flags & PeerUpdateFlag::FullInfo) { fullInfoUpdated(); - if (const auto channel = _peer ? _peer->asChannel() : nullptr) { + if (const auto channel = _peer->asChannel()) { if (channel->allowedReactions().paidEnabled) { session().credits().load(); } @@ -3440,7 +3440,7 @@ void HistoryWidget::messagesFailed(const MTP::Error &error, int requestId) { closeCurrent(); const auto wasAccount = not_null(&was->account()); if (const auto primary = Core::App().windowFor(wasAccount)) { - primary->showToast((was && was->isMegagroup()) + primary->showToast(was->isMegagroup() ? tr::lng_group_not_accessible(tr::now) : tr::lng_channel_not_accessible(tr::now)); } @@ -5111,7 +5111,7 @@ bool HistoryWidget::updateCmdStartShown() { const auto textSmall = _fieldCharsCountManager.count() > kSmallMenuAfter; const auto textChanged = _botMenu.button && ((_botMenu.text != bot->botInfo->botMenuButtonText) - || (_botMenu.small != textSmall)); + || (_botMenu.small != textSmall)); if (textChanged) { _botMenu.text = bot->botInfo->botMenuButtonText; if ((_botMenu.small = textSmall)) { diff --git a/Telegram/SourceFiles/history/view/controls/history_view_compose_controls.cpp b/Telegram/SourceFiles/history/view/controls/history_view_compose_controls.cpp index 2fdbc1d15..a2eefd668 100644 --- a/Telegram/SourceFiles/history/view/controls/history_view_compose_controls.cpp +++ b/Telegram/SourceFiles/history/view/controls/history_view_compose_controls.cpp @@ -381,7 +381,7 @@ void FieldHeader::init() { return; } const auto e = static_cast(event.get()); - const auto pos = e ? e->pos() : mapFromGlobal(QCursor::pos()); + const auto pos = e->pos(); const auto inPreviewRect = _clickableRect.contains(pos); const auto inPhotoEdit = _shownMessageHasPreview && _photoEditAllowed @@ -1191,9 +1191,7 @@ void ComposeControls::showStarted() { if (_attachBotsMenu) { _attachBotsMenu->hideFast(); } - if (_voiceRecordBar) { - _voiceRecordBar->hideFast(); - } + _voiceRecordBar->hideFast(); if (_autocomplete) { _autocomplete->hideFast(); } @@ -1213,9 +1211,7 @@ void ComposeControls::showFinished() { if (_attachBotsMenu) { _attachBotsMenu->hideFast(); } - if (_voiceRecordBar) { - _voiceRecordBar->hideFast(); - } + _voiceRecordBar->hideFast(); if (_autocomplete) { _autocomplete->hideFast(); } diff --git a/Telegram/SourceFiles/history/view/controls/history_view_voice_record_bar.cpp b/Telegram/SourceFiles/history/view/controls/history_view_voice_record_bar.cpp index c6fd7bff4..1f80fb15c 100644 --- a/Telegram/SourceFiles/history/view/controls/history_view_voice_record_bar.cpp +++ b/Telegram/SourceFiles/history/view/controls/history_view_voice_record_bar.cpp @@ -474,7 +474,7 @@ TTLButton::TTLButton( ) | rpl::start_with_next([=](bool toHide) { const auto isFirstTooltip = !Core::App().settings().ttlVoiceClickTooltipHidden(); - if (isFirstTooltip || (!isFirstTooltip && toHide)) { + if (isFirstTooltip || toHide) { _tooltip->toggleAnimated(!toHide); } }, _tooltip->lifetime()); diff --git a/Telegram/SourceFiles/history/view/media/history_view_theme_document.cpp b/Telegram/SourceFiles/history/view/media/history_view_theme_document.cpp index 66db74036..ba324f7e3 100644 --- a/Telegram/SourceFiles/history/view/media/history_view_theme_document.cpp +++ b/Telegram/SourceFiles/history/view/media/history_view_theme_document.cpp @@ -91,7 +91,8 @@ ThemeDocument::ThemeDocument( : File(parent, parent->data()) , _data(document) , _serviceWidth(serviceWidth) { - Expects(params.has_value() || _data->hasThumbnail() || _data->isTheme()); + Expects(params.has_value() + || (_data && (_data->hasThumbnail() || _data->isTheme()))); if (params) { _background = params->backgroundColors(); diff --git a/Telegram/SourceFiles/inline_bots/bot_attach_web_view.cpp b/Telegram/SourceFiles/inline_bots/bot_attach_web_view.cpp index 7a2f79071..df1111869 100644 --- a/Telegram/SourceFiles/inline_bots/bot_attach_web_view.cpp +++ b/Telegram/SourceFiles/inline_bots/bot_attach_web_view.cpp @@ -1366,7 +1366,7 @@ void WebViewInstance::show(ShowArgs &&args) { : attached->inMainMenu ? Button::RemoveFromMainMenu : Button::RemoveFromMenu); - const auto allowClipboardRead = v::is(_source) + const auto allowClipboardRead = v::is(_source) || v::is(_source) || (attached != end(bots) && (attached->inAttachMenu || attached->inMainMenu)); diff --git a/Telegram/SourceFiles/media/audio/media_audio.cpp b/Telegram/SourceFiles/media/audio/media_audio.cpp index 2b4c57084..86fe5ce21 100644 --- a/Telegram/SourceFiles/media/audio/media_audio.cpp +++ b/Telegram/SourceFiles/media/audio/media_audio.cpp @@ -806,10 +806,9 @@ void Mixer::externalSoundProgress(const AudioMsgId &audio) { } bool Mixer::checkCurrentALError(AudioMsgId::Type type) { - if (!Audio::PlaybackErrorHappened()) return true; - - const auto data = trackForType(type); - if (!data) { + if (!Audio::PlaybackErrorHappened()) { + return true; + } else if (const auto data = trackForType(type)) { setStoppedState(data, State::StoppedAtError); onError(data->state.id); } diff --git a/Telegram/SourceFiles/media/view/media_view_overlay_widget.cpp b/Telegram/SourceFiles/media/view/media_view_overlay_widget.cpp index f2314a616..921c39313 100644 --- a/Telegram/SourceFiles/media/view/media_view_overlay_widget.cpp +++ b/Telegram/SourceFiles/media/view/media_view_overlay_widget.cpp @@ -1234,7 +1234,8 @@ void OverlayWidget::documentUpdated(not_null document) { if (_document != document) { return; } else if (documentBubbleShown()) { - if ((_document->loading() && _docCancel->isHidden()) || (!_document->loading() && !_docCancel->isHidden())) { + if ((_document->loading() && _docCancel->isHidden()) + || (!_document->loading() && !_docCancel->isHidden())) { updateControls(); } else if (_document->loading()) { updateDocSize(); diff --git a/Telegram/SourceFiles/mtproto/session.cpp b/Telegram/SourceFiles/mtproto/session.cpp index 0a50a4561..842541e77 100644 --- a/Telegram/SourceFiles/mtproto/session.cpp +++ b/Telegram/SourceFiles/mtproto/session.cpp @@ -399,12 +399,10 @@ int32 Session::getState() const { if (_private) { const auto s = _private->getState(); - if (s == ConnectedState) { + if (s == ConnectedState + || s == ConnectingState + || s == DisconnectedState) { return s; - } else if (s == ConnectingState || s == DisconnectedState) { - if (result < 0) { - return s; - } } else if (s < 0) { if (result < 0 && s > result) { result = s; diff --git a/Telegram/SourceFiles/storage/details/storage_settings_scheme.cpp b/Telegram/SourceFiles/storage/details/storage_settings_scheme.cpp index 695f8f58a..d9421433e 100644 --- a/Telegram/SourceFiles/storage/details/storage_settings_scheme.cpp +++ b/Telegram/SourceFiles/storage/details/storage_settings_scheme.cpp @@ -1059,9 +1059,7 @@ bool ReadSetting( auto id = Ui::Emoji::IdFromOldKey(static_cast(i.key())); if (!id.isEmpty()) { auto index = Ui::Emoji::ColorIndexFromOldKey(i.value()); - if (index >= 0) { - variants.insert(id, index); - } + variants.insert(id, index); } } Core::App().settings().setLegacyEmojiVariants(std::move(variants)); diff --git a/Telegram/SourceFiles/ui/boxes/show_or_premium_box.cpp b/Telegram/SourceFiles/ui/boxes/show_or_premium_box.cpp index e44a172f1..426ddce42 100644 --- a/Telegram/SourceFiles/ui/boxes/show_or_premium_box.cpp +++ b/Telegram/SourceFiles/ui/boxes/show_or_premium_box.cpp @@ -117,8 +117,7 @@ void ShowOrPremiumBox( tr::lng_lastseen_shown_toast(tr::now), &st::showOrIconLastSeen, } - : (type == ShowOrPremium::ReadTime) - ? Skin{ + : Skin{ tr::lng_readtime_show_title(), tr::lng_readtime_show_about( lt_user, @@ -134,8 +133,7 @@ void ShowOrPremiumBox( tr::lng_readtime_premium_button(), tr::lng_readtime_shown_toast(tr::now), &st::showOrIconReadTime, - } - : Skin(); + }; box->setStyle(st::showOrBox); box->setWidth(st::boxWideWidth);