mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-13 20:57:07 +02:00
fix: tray ghost toggle
This commit is contained in:
parent
0a10adfdfd
commit
90d62514e9
5 changed files with 29 additions and 29 deletions
|
@ -164,7 +164,7 @@ namespace AyuSettings {
|
|||
voiceConfirmation = val;
|
||||
}
|
||||
|
||||
bool AyuGramSettings::getGhostModeValue() {
|
||||
bool AyuGramSettings::get_ghostModeEnabled() const {
|
||||
return (!sendReadPackets
|
||||
&& !sendOnlinePackets
|
||||
&& !sendUploadProgress
|
||||
|
@ -179,11 +179,11 @@ namespace AyuSettings {
|
|||
return editedMarkReactive.value();
|
||||
}
|
||||
|
||||
rpl::producer<int> get_showPeerId() {
|
||||
rpl::producer<int> get_showPeerIdReactive() {
|
||||
return showPeerIdReactive.value();
|
||||
}
|
||||
|
||||
rpl::producer<bool> get_ghostModeEnabled() {
|
||||
rpl::producer<bool> get_ghostModeEnabledReactive() {
|
||||
return ghostModeEnabled.value();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -122,7 +122,7 @@ namespace AyuSettings {
|
|||
void set_GIFConfirmation(bool val);
|
||||
void set_voiceConfirmation(bool val);
|
||||
|
||||
bool getGhostModeValue();
|
||||
bool get_ghostModeEnabled() const;
|
||||
};
|
||||
|
||||
AyuGramSettings &getInstance();
|
||||
|
@ -133,8 +133,8 @@ namespace AyuSettings {
|
|||
|
||||
rpl::producer<QString> get_deletedMarkReactive();
|
||||
rpl::producer<QString> get_editedMarkReactive();
|
||||
rpl::producer<int> get_showPeerId();
|
||||
rpl::producer<int> get_showPeerIdReactive();
|
||||
|
||||
// computed fields
|
||||
rpl::producer<bool> get_ghostModeEnabled();
|
||||
rpl::producer<bool> get_ghostModeEnabledReactive();
|
||||
}
|
||||
|
|
|
@ -260,7 +260,7 @@ namespace Settings {
|
|||
QString("Bot API")
|
||||
};
|
||||
|
||||
auto currentVal = AyuSettings::get_showPeerId() | rpl::map([=](int val) {
|
||||
auto currentVal = AyuSettings::get_showPeerIdReactive() | rpl::map([=](int val) {
|
||||
return options[val];
|
||||
});
|
||||
|
||||
|
|
|
@ -90,28 +90,28 @@ void Tray::rebuildMenu() {
|
|||
[=] { toggleSoundNotifications(); });
|
||||
}
|
||||
|
||||
// auto turnGhostModeText = _textUpdates.events(
|
||||
// ) | rpl::map([=] {
|
||||
// auto settings = AyuSettings::AyuGramSettings();
|
||||
// bool ghostModeEnabled = settings.getGhostModeValue();
|
||||
//
|
||||
// return ghostModeEnabled
|
||||
// ? tr::ayu_DisableGhostMode(tr::now)
|
||||
// : tr::ayu_EnableGhostMode(tr::now);
|
||||
// });
|
||||
auto turnGhostModeText = _textUpdates.events(
|
||||
) | rpl::map([=] {
|
||||
auto settings = &AyuSettings::getInstance();
|
||||
bool ghostModeEnabled = settings->get_ghostModeEnabled();
|
||||
|
||||
// _tray.addAction(rpl::single(QString("Toggle ghost mode")), [=] {
|
||||
// auto settings = &AyuSettings::getInstance();
|
||||
// bool ghostMode = (bool) AyuSettings::get_ghostModeEnabled();
|
||||
//
|
||||
// settings->set_sendReadPackets(!ghostMode);
|
||||
// settings->set_sendOnlinePackets(!ghostMode);
|
||||
// settings->set_sendUploadProgress(!ghostMode);
|
||||
//
|
||||
// settings->set_sendOfflinePacketAfterOnline(ghostMode);
|
||||
//
|
||||
// AyuSettings::save();
|
||||
// });
|
||||
return ghostModeEnabled
|
||||
? tr::ayu_DisableGhostMode(tr::now)
|
||||
: tr::ayu_EnableGhostMode(tr::now);
|
||||
});
|
||||
|
||||
_tray.addAction(std::move(turnGhostModeText), [=] {
|
||||
auto settings = &AyuSettings::getInstance();
|
||||
bool ghostMode = !settings->get_ghostModeEnabled();
|
||||
|
||||
settings->set_sendReadPackets(!ghostMode);
|
||||
settings->set_sendOnlinePackets(!ghostMode);
|
||||
settings->set_sendUploadProgress(!ghostMode);
|
||||
|
||||
settings->set_sendOfflinePacketAfterOnline(ghostMode);
|
||||
|
||||
AyuSettings::save();
|
||||
});
|
||||
|
||||
auto quitText = _textUpdates.events(
|
||||
) | rpl::map([=] {
|
||||
|
|
|
@ -851,7 +851,7 @@ void MainMenu::setupMenu() {
|
|||
_ghostModeToggle = addAction(
|
||||
tr::ayu_DrawerGhostModeToggle(),
|
||||
{&st::ayuGhostIcon, kIconPurple}
|
||||
)->toggleOn(AyuSettings::get_ghostModeEnabled());
|
||||
)->toggleOn(AyuSettings::get_ghostModeEnabledReactive());
|
||||
|
||||
_ghostModeToggle->toggledChanges(
|
||||
) | rpl::start_with_next([=](bool ghostMode) {
|
||||
|
|
Loading…
Add table
Reference in a new issue