diff --git a/Telegram/SourceFiles/ayu/ayu_settings.cpp b/Telegram/SourceFiles/ayu/ayu_settings.cpp index 2c012c713..44eb016a6 100644 --- a/Telegram/SourceFiles/ayu/ayu_settings.cpp +++ b/Telegram/SourceFiles/ayu/ayu_settings.cpp @@ -18,6 +18,8 @@ namespace AyuSettings { rpl::variable sendReadPacketsReactive; rpl::variable sendOnlinePacketsReactive; + rpl::variable sendUploadProgressReactive; + rpl::variable sendOfflinePacketAfterOnlineReactive; rpl::variable deletedMarkReactive; rpl::variable editedMarkReactive; @@ -27,22 +29,39 @@ namespace AyuSettings { rpl::lifetime lifetime = rpl::lifetime(); + bool ghostModeEnabled_util(AyuGramSettings &settingsUtil) { + return (!settingsUtil.sendReadPackets + && !settingsUtil.sendOnlinePackets + && !settingsUtil.sendUploadProgress + && settingsUtil.sendOfflinePacketAfterOnline); + } + void initialize() { if (settings.has_value()) { return; } - settings = std::optional(AyuGramSettings()); + settings = AyuGramSettings(); sendReadPacketsReactive.value() | rpl::filter([=](bool val) { return (val != settings->sendReadPackets); }) | rpl::start_with_next([=](bool val) { - ghostModeEnabled = !settings->sendReadPackets && !settings->sendOnlinePackets; + ghostModeEnabled = ghostModeEnabled_util(settings.value()); }, lifetime); sendOnlinePacketsReactive.value() | rpl::filter([=](bool val) { return (val != settings->sendOnlinePackets); }) | rpl::start_with_next([=](bool val) { - ghostModeEnabled = !settings->sendReadPackets && !settings->sendOnlinePackets; + ghostModeEnabled = ghostModeEnabled_util(settings.value()); + }, lifetime); + sendUploadProgressReactive.value() | rpl::filter([=](bool val) { + return (val != settings->sendUploadProgress); + }) | rpl::start_with_next([=](bool val) { + ghostModeEnabled = ghostModeEnabled_util(settings.value()); + }, lifetime); + sendOfflinePacketAfterOnlineReactive.value() | rpl::filter([=](bool val) { + return (val != settings->sendOfflinePacketAfterOnline); + }) | rpl::start_with_next([=](bool val) { + ghostModeEnabled = ghostModeEnabled_util(settings.value()); }, lifetime); } @@ -54,7 +73,7 @@ namespace AyuSettings { editedMarkReactive = settings->editedMark; showPeerIdReactive = settings->showPeerId; - ghostModeEnabled = !settings->sendReadPackets && !settings->sendOnlinePackets; + ghostModeEnabled = ghostModeEnabled_util(settings.value()); } AyuGramSettings &getInstance() { @@ -102,10 +121,12 @@ namespace AyuSettings { void AyuGramSettings::set_sendUploadProgress(bool val) { sendUploadProgress = val; + sendUploadProgressReactive = val; } void AyuGramSettings::set_sendOfflinePacketAfterOnline(bool val) { sendOfflinePacketAfterOnline = val; + sendOfflinePacketAfterOnlineReactive = val; } void AyuGramSettings::set_markReadAfterSend(bool val) { @@ -167,11 +188,8 @@ namespace AyuSettings { voiceConfirmation = val; } - bool AyuGramSettings::get_ghostModeEnabled() const { - return (!sendReadPackets - && !sendOnlinePackets - && !sendUploadProgress - && sendOfflinePacketAfterOnline); + bool get_ghostModeEnabled() { + return ghostModeEnabled.current(); } rpl::producer get_deletedMarkReactive() { diff --git a/Telegram/SourceFiles/ayu/ayu_settings.h b/Telegram/SourceFiles/ayu/ayu_settings.h index 720634568..554d43a40 100644 --- a/Telegram/SourceFiles/ayu/ayu_settings.h +++ b/Telegram/SourceFiles/ayu/ayu_settings.h @@ -112,8 +112,6 @@ namespace AyuSettings { void set_GIFConfirmation(bool val); void set_voiceConfirmation(bool val); - - bool get_ghostModeEnabled() const; }; NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE( @@ -151,5 +149,7 @@ namespace AyuSettings { rpl::producer get_showPeerIdReactive(); // computed fields + bool get_ghostModeEnabled(); + rpl::producer get_ghostModeEnabledReactive(); } diff --git a/Telegram/SourceFiles/ayu/ayu_state.h b/Telegram/SourceFiles/ayu/ayu_state.h index 1fbb0c287..164ade831 100644 --- a/Telegram/SourceFiles/ayu/ayu_state.h +++ b/Telegram/SourceFiles/ayu/ayu_state.h @@ -36,5 +36,6 @@ namespace AyuState { } void setAllowSendReadPacket(bool val, int resetAfter = 1); + bool getAllowSendPacket(); } \ No newline at end of file diff --git a/Telegram/SourceFiles/ayu/sync/models.h b/Telegram/SourceFiles/ayu/sync/models.h index d496a95fa..827994c49 100644 --- a/Telegram/SourceFiles/ayu/sync/models.h +++ b/Telegram/SourceFiles/ayu/sync/models.h @@ -15,6 +15,7 @@ class SyncBatch : public SyncEvent { class SyncBatchArgs { std::vector events; }; + SyncBatchArgs args; }; @@ -27,6 +28,7 @@ class SyncRead : public SyncEvent { int untilId; int unread; }; + SyncReadArgs args; }; @@ -37,6 +39,7 @@ class SyncForce : public SyncEvent { class SyncForceArgs { int fromDate; }; + SyncForceArgs args; }; @@ -46,6 +49,7 @@ class SyncForceFinish : public SyncEvent { class SyncForceFinishArgs { }; + SyncForceFinishArgs args; }; diff --git a/Telegram/SourceFiles/ayu/sync/utils/ayu_pipe_wrapper.cpp b/Telegram/SourceFiles/ayu/sync/utils/ayu_pipe_wrapper.cpp index be18f597e..e5aabff67 100644 --- a/Telegram/SourceFiles/ayu/sync/utils/ayu_pipe_wrapper.cpp +++ b/Telegram/SourceFiles/ayu/sync/utils/ayu_pipe_wrapper.cpp @@ -32,7 +32,7 @@ json ayu_pipe_wrapper::receive() { char buff[4096]; while (length > 0) { - auto readSize = std::min(length, (int)sizeof(buff)); + auto readSize = std::min(length, (int) sizeof(buff)); is.read(buff, readSize); sb.sputn(buff, readSize); length -= readSize; diff --git a/Telegram/SourceFiles/ayu/sync/utils/ayu_pipe_wrapper.h b/Telegram/SourceFiles/ayu/sync/utils/ayu_pipe_wrapper.h index 2151ff118..04957cf4e 100644 --- a/Telegram/SourceFiles/ayu/sync/utils/ayu_pipe_wrapper.h +++ b/Telegram/SourceFiles/ayu/sync/utils/ayu_pipe_wrapper.h @@ -17,7 +17,9 @@ class ayu_pipe_wrapper { public: template void send(T obj); + json receive(); + private: nes::basic_pipe_istream is{"AyuSync"}; nes::basic_pipe_ostream os{"AyuSync"}; diff --git a/Telegram/SourceFiles/ayu/ui/boxes/confirmation_box.h b/Telegram/SourceFiles/ayu/ui/boxes/confirmation_box.h index c9f06464f..a9d53f1f6 100644 --- a/Telegram/SourceFiles/ayu/ui/boxes/confirmation_box.h +++ b/Telegram/SourceFiles/ayu/ui/boxes/confirmation_box.h @@ -15,12 +15,13 @@ namespace AyuUi { protected: void prepare() override; + void resizeEvent(QResizeEvent *e) override; private: void ReadAllPeers(); not_null _controller; - object_ptr _text = { nullptr }; + object_ptr _text = {nullptr}; }; } \ No newline at end of file diff --git a/Telegram/SourceFiles/ayu/ui/boxes/voice_confirmation_box.cpp b/Telegram/SourceFiles/ayu/ui/boxes/voice_confirmation_box.cpp index 0a375e813..c0e20c475 100644 --- a/Telegram/SourceFiles/ayu/ui/boxes/voice_confirmation_box.cpp +++ b/Telegram/SourceFiles/ayu/ui/boxes/voice_confirmation_box.cpp @@ -94,9 +94,9 @@ namespace AyuUi { object_ptr MakeInformBox(v::text::data text) { return MakeConfirmBox({ - .text = std::move(text), - .inform = true, - }); + .text = std::move(text), + .inform = true, + }); } } // namespace AyuUi diff --git a/Telegram/SourceFiles/ayu/ui/boxes/voice_confirmation_box.h b/Telegram/SourceFiles/ayu/ui/boxes/voice_confirmation_box.h index 2c68ed69e..9b1ce65a1 100644 --- a/Telegram/SourceFiles/ayu/ui/boxes/voice_confirmation_box.h +++ b/Telegram/SourceFiles/ayu/ui/boxes/voice_confirmation_box.h @@ -11,10 +11,11 @@ #include "ui/boxes/confirm_box.h" namespace AyuUi { - void VoiceConfirmBox(not_null box, Ui::ConfirmBoxArgs &&args); + void VoiceConfirmBox(not_null box, Ui::ConfirmBoxArgs &&args); [[nodiscard]] object_ptr MakeConfirmBox( Ui::ConfirmBoxArgs &&args); + [[nodiscard]] object_ptr MakeInformBox(v::text::data text); } // namespace Ui diff --git a/Telegram/SourceFiles/ayu/ui/settings/settings_ayu.h b/Telegram/SourceFiles/ayu/ui/settings/settings_ayu.h index f6f581c4c..cf6826c88 100644 --- a/Telegram/SourceFiles/ayu/ui/settings/settings_ayu.h +++ b/Telegram/SourceFiles/ayu/ui/settings/settings_ayu.h @@ -26,16 +26,23 @@ namespace Settings { private: void SetupGhostEssentials(not_null container); - void SetupSpyEssentials(not_null container); - void SetupQoLToggles(not_null container); - void SetupCustomization(not_null container, not_null controller); - void SetupShowPeerId(not_null container, not_null controller); + void SetupSpyEssentials(not_null container); + + void SetupQoLToggles(not_null container); + + void + SetupCustomization(not_null container, not_null controller); + + void + SetupShowPeerId(not_null container, not_null controller); + void SetupRecentStickersLimitSlider(not_null container); void SetupBetaFunctions(not_null container); void SetupAyuGramSettings(not_null container, not_null null); + void setupContent(not_null controller); }; diff --git a/Telegram/SourceFiles/ayu/ui/utils/ayu_profile_values.cpp b/Telegram/SourceFiles/ayu/ui/utils/ayu_profile_values.cpp index 1f4c92148..aa19bf79c 100644 --- a/Telegram/SourceFiles/ayu/ui/utils/ayu_profile_values.cpp +++ b/Telegram/SourceFiles/ayu/ui/utils/ayu_profile_values.cpp @@ -14,7 +14,7 @@ constexpr auto kMaxChannelId = -1000000000000; -QString IDString(not_null peer) { +QString IDString(not_null peer) { auto resultId = QString::number(peerIsUser(peer->id) ? peerToUser(peer->id).bare : peerIsChat(peer->id) @@ -35,6 +35,6 @@ QString IDString(not_null peer) { return resultId; } -rpl::producer IDValue(not_null peer) { +rpl::producer IDValue(not_null peer) { return rpl::single(IDString(peer)) | Ui::Text::ToWithEntities(); } \ No newline at end of file diff --git a/Telegram/SourceFiles/ayu/ui/utils/ayu_profile_values.h b/Telegram/SourceFiles/ayu/ui/utils/ayu_profile_values.h index 4b0f2cb70..c7577ab6c 100644 --- a/Telegram/SourceFiles/ayu/ui/utils/ayu_profile_values.h +++ b/Telegram/SourceFiles/ayu/ui/utils/ayu_profile_values.h @@ -8,5 +8,6 @@ #pragma once -QString IDString(not_null peer); -rpl::producer IDValue(not_null peer); \ No newline at end of file +QString IDString(not_null peer); + +rpl::producer IDValue(not_null peer); \ No newline at end of file diff --git a/Telegram/SourceFiles/tray.cpp b/Telegram/SourceFiles/tray.cpp index 91205e853..2928b69ef 100644 --- a/Telegram/SourceFiles/tray.cpp +++ b/Telegram/SourceFiles/tray.cpp @@ -92,8 +92,7 @@ void Tray::rebuildMenu() { auto turnGhostModeText = _textUpdates.events( ) | rpl::map([=] { - auto settings = &AyuSettings::getInstance(); - bool ghostModeEnabled = settings->get_ghostModeEnabled(); + bool ghostModeEnabled = AyuSettings::get_ghostModeEnabled(); return ghostModeEnabled ? tr::ayu_DisableGhostMode(tr::now) @@ -102,7 +101,7 @@ void Tray::rebuildMenu() { _tray.addAction(std::move(turnGhostModeText), [=] { auto settings = &AyuSettings::getInstance(); - bool ghostMode = !settings->get_ghostModeEnabled(); + bool ghostMode = !AyuSettings::get_ghostModeEnabled(); settings->set_sendReadPackets(!ghostMode); settings->set_sendOnlinePackets(!ghostMode);