diff --git a/Telegram/SourceFiles/apiwrap.cpp b/Telegram/SourceFiles/apiwrap.cpp index 54aa7eeb33..fd9becfc29 100644 --- a/Telegram/SourceFiles/apiwrap.cpp +++ b/Telegram/SourceFiles/apiwrap.cpp @@ -4016,7 +4016,7 @@ void ApiWrap::sendMessage( ? Data::CanSendTexts(topic) : Data::CanSendTexts(peer); - if (!canSendTexts && !AyuForward::isForwarding(peer->id) || Api::SendDice(message)) { + if ((!canSendTexts && !AyuForward::isForwarding(peer->id)) || Api::SendDice(message)) { return; } local().saveRecentSentHashtags(textWithTags.text); diff --git a/Telegram/SourceFiles/ayu/features/filters/filters_controller.cpp b/Telegram/SourceFiles/ayu/features/filters/filters_controller.cpp index 25ea95f7dc..84fc5156a7 100644 --- a/Telegram/SourceFiles/ayu/features/filters/filters_controller.cpp +++ b/Telegram/SourceFiles/ayu/features/filters/filters_controller.cpp @@ -59,7 +59,7 @@ std::optional isFiltered(const QString &str, uint64 dialogId) { const auto reversed = pattern.reversed; - if (!reversed && match || reversed && !match) { + if ((!reversed && match) || (reversed && !match)) { return true; } return false; @@ -89,7 +89,7 @@ std::optional isFiltered(const QString &str, uint64 dialogId) { bool isEnabled(not_null peer) { const auto &settings = AyuSettings::getInstance(); - return settings.filtersEnabled && (settings.filtersEnabledInChats || !peer->isMegagroup() && !peer->isGigagroup() && !peer->isUser()); + return settings.filtersEnabled && (settings.filtersEnabledInChats || (!peer->isMegagroup() && !peer->isGigagroup() && !peer->isUser())); } bool isBlocked(const not_null item) { @@ -115,8 +115,8 @@ bool isBlocked(const not_null item) { return settings.filtersEnabled && ( - item->from()->isUser() && ShadowBanUtils::isShadowBanned(getDialogIdFromPeer(item->from())) || - settings.hideFromBlocked && blocked + (item->from()->isUser() && ShadowBanUtils::isShadowBanned(getDialogIdFromPeer(item->from()))) || + (settings.hideFromBlocked && blocked) ); } diff --git a/Telegram/SourceFiles/ayu/features/filters/filters_utils.cpp b/Telegram/SourceFiles/ayu/features/filters/filters_utils.cpp index a81c847e4e..ee63d6aeaf 100644 --- a/Telegram/SourceFiles/ayu/features/filters/filters_utils.cpp +++ b/Telegram/SourceFiles/ayu/features/filters/filters_utils.cpp @@ -278,7 +278,7 @@ int typeOfMessage(const HistoryItem *item) { if (media->giveawayResults()) { return 28; // TYPE_GIVEAWAY_RESULTS } - if (const auto dice = dynamic_cast(media)) { + if (dynamic_cast(media)) { return 15; // TYPE_ANIMATED_STICKER } if (media->photo()) { diff --git a/Telegram/SourceFiles/ayu/features/filters/filters_utils.h b/Telegram/SourceFiles/ayu/features/filters/filters_utils.h index d96dd9f842..e816ced68f 100644 --- a/Telegram/SourceFiles/ayu/features/filters/filters_utils.h +++ b/Telegram/SourceFiles/ayu/features/filters/filters_utils.h @@ -26,7 +26,7 @@ struct ApplyChanges std::map peersToBeResolved; - auto operator<=>(const ApplyChanges&) const = default; + bool operator==(const ApplyChanges&) const = default; }; diff --git a/Telegram/SourceFiles/ayu/features/forward/ayu_forward.cpp b/Telegram/SourceFiles/ayu/features/forward/ayu_forward.cpp index 215e7a64a9..6cdeb0858e 100644 --- a/Telegram/SourceFiles/ayu/features/forward/ayu_forward.cpp +++ b/Telegram/SourceFiles/ayu/features/forward/ayu_forward.cpp @@ -38,7 +38,7 @@ bool isForwarding(const PeerId &id) { return state.state != ForwardState::State::Finished && state.currentChunk < state.totalChunks && !state.stopRequested - && (state.totalChunks && state.totalMessages || state.state == ForwardState::State::Downloading); + && ((state.totalChunks && state.totalMessages) || state.state == ForwardState::State::Downloading); } return false; } @@ -399,9 +399,9 @@ void forwardMessages( auto &file = preparedMedia.files[j]; QFile f(file.path); - if (groupMedia[j]->photo() && f.size() < groupMedia[j]->photo()->imageByteSize(Data::PhotoSize::Large) - || - groupMedia[j]->document() && f.size() < groupMedia[j]->document()->size + if ( + (groupMedia[j]->photo() && f.size() < groupMedia[j]->photo()->imageByteSize(Data::PhotoSize::Large)) || + (groupMedia[j]->document() && f.size() < groupMedia[j]->document()->size) ) { preparedMedia.files.erase(preparedMedia.files.begin() + j); } diff --git a/Telegram/SourceFiles/ayu/features/forward/ayu_sync.cpp b/Telegram/SourceFiles/ayu/features/forward/ayu_sync.cpp index b430686b02..9ce8b778e5 100644 --- a/Telegram/SourceFiles/ayu/features/forward/ayu_sync.cpp +++ b/Telegram/SourceFiles/ayu/features/forward/ayu_sync.cpp @@ -21,37 +21,6 @@ #include "storage/file_download_mtproto.h" #include "storage/localimageloader.h" -class TimedCountDownLatch -{ -public: - explicit TimedCountDownLatch(int count) - : count_(count) { - } - - void countDown() { - std::unique_lock lock(mutex_); - if (count_ > 0) { - count_--; - } - if (count_ == 0) { - cv_.notify_all(); - } - } - - bool await(std::chrono::milliseconds timeout) { - std::unique_lock lock(mutex_); - if (count_ == 0) { - return true; - } - return cv_.wait_for(lock, timeout, [this] { return count_ == 0; }); - } - -private: - std::mutex mutex_; - std::condition_variable cv_; - int count_; -}; - namespace AyuSync { QString pathForSave(not_null session) { diff --git a/Telegram/SourceFiles/ayu/features/translator/implementations/base.cpp b/Telegram/SourceFiles/ayu/features/translator/implementations/base.cpp index 00527dbb29..1eadfa2700 100644 --- a/Telegram/SourceFiles/ayu/features/translator/implementations/base.cpp +++ b/Telegram/SourceFiles/ayu/features/translator/implementations/base.cpp @@ -4,8 +4,6 @@ // but be respectful and credit the original author. // // Copyright @Radolyn, 2025 -#pragma once - #include #include #include diff --git a/Telegram/SourceFiles/ayu/ui/context_menu/context_menu.cpp b/Telegram/SourceFiles/ayu/ui/context_menu/context_menu.cpp index 231abf58e7..d332186a32 100644 --- a/Telegram/SourceFiles/ayu/ui/context_menu/context_menu.cpp +++ b/Telegram/SourceFiles/ayu/ui/context_menu/context_menu.cpp @@ -245,7 +245,7 @@ void AddJumpToBeginningAction(PeerData *peerData, QDate(2013, 8, 1), [=](not_null peer, MsgId id) { - if (const auto strong = weak.get()) { + if (weak.get()) { callback(peer, id); } }); @@ -772,7 +772,7 @@ void AddReadUntilAction(not_null menu, HistoryItem *item) { } void AddBurnAction(not_null menu, HistoryItem *item) { - if (!item->media() || item->media()->ttlSeconds() <= 0 && item->unsupportedTTL() <= 0 || item->out() || + if (!item->media() || (item->media()->ttlSeconds() <= 0 && item->unsupportedTTL() <= 0) || item->out() || !item->isUnreadMedia()) { return; } diff --git a/Telegram/SourceFiles/ayu/utils/telegram_helpers.cpp b/Telegram/SourceFiles/ayu/utils/telegram_helpers.cpp index 04fcce25ff..62400a8ced 100644 --- a/Telegram/SourceFiles/ayu/utils/telegram_helpers.cpp +++ b/Telegram/SourceFiles/ayu/utils/telegram_helpers.cpp @@ -885,7 +885,7 @@ TextWithTags extractText(not_null item) { if (const auto poll = media->poll()) { text.append("\xF0\x9F\x93\x8A ") // 📊 .append(poll->question.text).append("\n"); - for (const auto answer : poll->answers) { + for (const auto &answer : poll->answers) { text.append("• ").append(answer.text.text).append("\n"); } } @@ -909,14 +909,13 @@ bool mediaDownloadable(const Data::Media *media) { } void resolveAllChats(const std::map &peers) { - // not sure is this works auto session = currentSession(); crl::async([=, &session] { while (!peers.empty()) { for (const auto &[id, username] : peers) { - std::latch latch(1); + auto latch = std::make_shared(1); auto onSuccess = [=, &latch](const MTPChatInvite &invite) { @@ -935,18 +934,18 @@ void resolveAllChats(const std::map &peers) { { }); - latch.count_down(); + latch->countDown(); }; auto onFail = [=, &latch](const MTP::Error &error) { if (MTP::IsFloodError(error.type())) { std::this_thread::sleep_for(std::chrono::seconds(20)); } - latch.count_down(); + latch->countDown(); }; session->api().checkChatInvite(username, onSuccess, onFail); - latch.wait(); + latch->await(std::chrono::seconds(20)); } } }); diff --git a/Telegram/SourceFiles/ayu/utils/telegram_helpers.h b/Telegram/SourceFiles/ayu/utils/telegram_helpers.h index be46d6eea9..3c9bfece73 100644 --- a/Telegram/SourceFiles/ayu/utils/telegram_helpers.h +++ b/Telegram/SourceFiles/ayu/utils/telegram_helpers.h @@ -16,6 +16,37 @@ using UsernameResolverCallback = Fn; +class TimedCountDownLatch +{ +public: + explicit TimedCountDownLatch(int count) + : count_(count) { + } + + void countDown() { + std::unique_lock lock(mutex_); + if (count_ > 0) { + count_--; + } + if (count_ == 0) { + cv_.notify_all(); + } + } + + bool await(std::chrono::milliseconds timeout) { + std::unique_lock lock(mutex_); + if (count_ == 0) { + return true; + } + return cv_.wait_for(lock, timeout, [this] { return count_ == 0; }); + } + +private: + std::mutex mutex_; + std::condition_variable cv_; + int count_; +}; + Main::Session *getSession(ID userId); void dispatchToMainThread(const std::function &callback, int delay = 0); ID getDialogIdFromPeer(not_null peer); diff --git a/Telegram/SourceFiles/media/view/media_view_overlay_widget.cpp b/Telegram/SourceFiles/media/view/media_view_overlay_widget.cpp index e9ec9ff875..d642c8bf12 100644 --- a/Telegram/SourceFiles/media/view/media_view_overlay_widget.cpp +++ b/Telegram/SourceFiles/media/view/media_view_overlay_widget.cpp @@ -1111,7 +1111,7 @@ QSize OverlayWidget::flipSizeByRotation(QSize size) const { } bool OverlayWidget::hasCopyMediaRestriction(bool skipPremiumCheck) const { - if (const auto story = _stories ? _stories->story() : nullptr) { + if (true) { // AyuGram: removed; allow downloading any stories return false; }