Replaced observable in Window::Notifications::System with rpl.
This commit is contained in:
parent
2c50d3d87b
commit
aad38c2809
|
@ -133,13 +133,13 @@ InnerWidget::InnerWidget(
|
||||||
update();
|
update();
|
||||||
}, lifetime());
|
}, lifetime());
|
||||||
|
|
||||||
subscribe(Core::App().notifications().settingsChanged(), [=](
|
Core::App().notifications().settingsChanged(
|
||||||
Window::Notifications::ChangeType change) {
|
) | rpl::start_with_next([=](Window::Notifications::ChangeType change) {
|
||||||
if (change == Window::Notifications::ChangeType::CountMessages) {
|
if (change == Window::Notifications::ChangeType::CountMessages) {
|
||||||
// Folder rows change their unread badge with this setting.
|
// Folder rows change their unread badge with this setting.
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
});
|
}, lifetime());
|
||||||
|
|
||||||
session().data().contactsLoaded().changes(
|
session().data().contactsLoaded().changes(
|
||||||
) | rpl::start_with_next([=] {
|
) | rpl::start_with_next([=] {
|
||||||
|
|
|
@ -756,13 +756,13 @@ void MainWindow::toggleDisplayNotifyFromTray() {
|
||||||
}
|
}
|
||||||
account().session().saveSettings();
|
account().session().saveSettings();
|
||||||
using Change = Window::Notifications::ChangeType;
|
using Change = Window::Notifications::ChangeType;
|
||||||
auto &changes = Core::App().notifications().settingsChanged();
|
auto ¬ifications = Core::App().notifications();
|
||||||
changes.notify(Change::DesktopEnabled);
|
notifications.notifySettingsChanged(Change::DesktopEnabled);
|
||||||
if (soundNotifyChanged) {
|
if (soundNotifyChanged) {
|
||||||
changes.notify(Change::SoundEnabled);
|
notifications.notifySettingsChanged(Change::SoundEnabled);
|
||||||
}
|
}
|
||||||
if (flashBounceNotifyChanged) {
|
if (flashBounceNotifyChanged) {
|
||||||
changes.notify(Change::FlashBounceEnabled);
|
notifications.notifySettingsChanged(Change::FlashBounceEnabled);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -193,7 +193,7 @@ void NotificationsCount::setCount(int count) {
|
||||||
if (count != Core::App().settings().notificationsCount()) {
|
if (count != Core::App().settings().notificationsCount()) {
|
||||||
Core::App().settings().setNotificationsCount(count);
|
Core::App().settings().setNotificationsCount(count);
|
||||||
Core::App().saveSettingsDelayed();
|
Core::App().saveSettingsDelayed();
|
||||||
Core::App().notifications().settingsChanged().notify(
|
Core::App().notifications().notifySettingsChanged(
|
||||||
ChangeType::MaxCount);
|
ChangeType::MaxCount);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -357,7 +357,7 @@ void NotificationsCount::setOverCorner(ScreenCorner corner) {
|
||||||
_isOverCorner = true;
|
_isOverCorner = true;
|
||||||
setCursor(style::cur_pointer);
|
setCursor(style::cur_pointer);
|
||||||
Global::SetNotificationsDemoIsShown(true);
|
Global::SetNotificationsDemoIsShown(true);
|
||||||
Core::App().notifications().settingsChanged().notify(
|
Core::App().notifications().notifySettingsChanged(
|
||||||
ChangeType::DemoIsShown);
|
ChangeType::DemoIsShown);
|
||||||
}
|
}
|
||||||
_overCorner = corner;
|
_overCorner = corner;
|
||||||
|
@ -393,7 +393,8 @@ void NotificationsCount::clearOverCorner() {
|
||||||
_isOverCorner = false;
|
_isOverCorner = false;
|
||||||
setCursor(style::cur_default);
|
setCursor(style::cur_default);
|
||||||
Global::SetNotificationsDemoIsShown(false);
|
Global::SetNotificationsDemoIsShown(false);
|
||||||
Core::App().notifications().settingsChanged().notify(ChangeType::DemoIsShown);
|
Core::App().notifications().notifySettingsChanged(
|
||||||
|
ChangeType::DemoIsShown);
|
||||||
|
|
||||||
for_const (const auto &samples, _cornerSamples) {
|
for_const (const auto &samples, _cornerSamples) {
|
||||||
for_const (const auto widget, samples) {
|
for_const (const auto widget, samples) {
|
||||||
|
@ -420,7 +421,7 @@ void NotificationsCount::mouseReleaseEvent(QMouseEvent *e) {
|
||||||
if (_chosenCorner != Core::App().settings().notificationsCorner()) {
|
if (_chosenCorner != Core::App().settings().notificationsCorner()) {
|
||||||
Core::App().settings().setNotificationsCorner(_chosenCorner);
|
Core::App().settings().setNotificationsCorner(_chosenCorner);
|
||||||
Core::App().saveSettingsDelayed();
|
Core::App().saveSettingsDelayed();
|
||||||
Core::App().notifications().settingsChanged().notify(
|
Core::App().notifications().notifySettingsChanged(
|
||||||
ChangeType::Corner);
|
ChangeType::Corner);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -740,7 +741,7 @@ void SetupNotificationsContent(
|
||||||
using Change = Window::Notifications::ChangeType;
|
using Change = Window::Notifications::ChangeType;
|
||||||
const auto changed = [=](Change change) {
|
const auto changed = [=](Change change) {
|
||||||
Core::App().saveSettingsDelayed();
|
Core::App().saveSettingsDelayed();
|
||||||
Core::App().notifications().settingsChanged().notify(change);
|
Core::App().notifications().notifySettingsChanged(change);
|
||||||
};
|
};
|
||||||
desktop->checkedChanges(
|
desktop->checkedChanges(
|
||||||
) | rpl::filter([](bool checked) {
|
) | rpl::filter([](bool checked) {
|
||||||
|
@ -812,8 +813,7 @@ void SetupNotificationsContent(
|
||||||
changed(Change::CountMessages);
|
changed(Change::CountMessages);
|
||||||
}, count->lifetime());
|
}, count->lifetime());
|
||||||
|
|
||||||
base::ObservableViewer(
|
Core::App().notifications().settingsChanged(
|
||||||
Core::App().notifications().settingsChanged()
|
|
||||||
) | rpl::start_with_next([=](Change change) {
|
) | rpl::start_with_next([=](Change change) {
|
||||||
if (change == Change::DesktopEnabled) {
|
if (change == Change::DesktopEnabled) {
|
||||||
desktop->setChecked(Core::App().settings().desktopNotify());
|
desktop->setChecked(Core::App().settings().desktopNotify());
|
||||||
|
|
|
@ -52,7 +52,8 @@ constexpr auto kSystemAlertDuration = crl::time(0);
|
||||||
System::System()
|
System::System()
|
||||||
: _waitTimer([=] { showNext(); })
|
: _waitTimer([=] { showNext(); })
|
||||||
, _waitForAllGroupedTimer([=] { showGrouped(); }) {
|
, _waitForAllGroupedTimer([=] { showGrouped(); }) {
|
||||||
subscribe(settingsChanged(), [=](ChangeType type) {
|
settingsChanged(
|
||||||
|
) | rpl::start_with_next([=](ChangeType type) {
|
||||||
if (type == ChangeType::DesktopEnabled) {
|
if (type == ChangeType::DesktopEnabled) {
|
||||||
clearAll();
|
clearAll();
|
||||||
} else if (type == ChangeType::ViewParams) {
|
} else if (type == ChangeType::ViewParams) {
|
||||||
|
@ -61,7 +62,7 @@ System::System()
|
||||||
|| type == ChangeType::CountMessages) {
|
|| type == ChangeType::CountMessages) {
|
||||||
Core::App().domain().notifyUnreadBadgeChanged();
|
Core::App().domain().notifyUnreadBadgeChanged();
|
||||||
}
|
}
|
||||||
});
|
}, lifetime());
|
||||||
}
|
}
|
||||||
|
|
||||||
void System::createManager() {
|
void System::createManager() {
|
||||||
|
@ -578,6 +579,14 @@ void System::updateAll() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rpl::producer<ChangeType> System::settingsChanged() const {
|
||||||
|
return _settingsChanged.events();
|
||||||
|
}
|
||||||
|
|
||||||
|
void System::notifySettingsChanged(ChangeType type) {
|
||||||
|
return _settingsChanged.fire(std::move(type));
|
||||||
|
}
|
||||||
|
|
||||||
Manager::DisplayOptions Manager::getNotificationOptions(
|
Manager::DisplayOptions Manager::getNotificationOptions(
|
||||||
HistoryItem *item) const {
|
HistoryItem *item) const {
|
||||||
const auto hideEverything = Core::App().passcodeLocked()
|
const auto hideEverything = Core::App().passcodeLocked()
|
||||||
|
|
|
@ -71,7 +71,7 @@ namespace Notifications {
|
||||||
|
|
||||||
class Manager;
|
class Manager;
|
||||||
|
|
||||||
class System final : private base::Subscriber {
|
class System final {
|
||||||
public:
|
public:
|
||||||
System();
|
System();
|
||||||
~System();
|
~System();
|
||||||
|
@ -92,8 +92,11 @@ public:
|
||||||
void clearAllFast();
|
void clearAllFast();
|
||||||
void updateAll();
|
void updateAll();
|
||||||
|
|
||||||
base::Observable<ChangeType> &settingsChanged() {
|
[[nodiscard]] rpl::producer<ChangeType> settingsChanged() const;
|
||||||
return _settingsChanged;
|
void notifySettingsChanged(ChangeType type);
|
||||||
|
|
||||||
|
[[nodiscard]] rpl::lifetime &lifetime() {
|
||||||
|
return _lifetime;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -132,7 +135,7 @@ private:
|
||||||
|
|
||||||
std::unique_ptr<Manager> _manager;
|
std::unique_ptr<Manager> _manager;
|
||||||
|
|
||||||
base::Observable<ChangeType> _settingsChanged;
|
rpl::event_stream<ChangeType> _settingsChanged;
|
||||||
|
|
||||||
std::unique_ptr<Media::Audio::Track> _soundTrack;
|
std::unique_ptr<Media::Audio::Track> _soundTrack;
|
||||||
|
|
||||||
|
@ -140,6 +143,8 @@ private:
|
||||||
uint64 _lastHistorySessionId = 0;
|
uint64 _lastHistorySessionId = 0;
|
||||||
FullMsgId _lastHistoryItemId;
|
FullMsgId _lastHistoryItemId;
|
||||||
|
|
||||||
|
rpl::lifetime _lifetime;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class Manager {
|
class Manager {
|
||||||
|
|
|
@ -73,9 +73,10 @@ std::unique_ptr<Manager> Create(System *system) {
|
||||||
Manager::Manager(System *system)
|
Manager::Manager(System *system)
|
||||||
: Notifications::Manager(system)
|
: Notifications::Manager(system)
|
||||||
, _inputCheckTimer([=] { checkLastInput(); }) {
|
, _inputCheckTimer([=] { checkLastInput(); }) {
|
||||||
subscribe(system->settingsChanged(), [this](ChangeType change) {
|
system->settingsChanged(
|
||||||
|
) | rpl::start_with_next([=](ChangeType change) {
|
||||||
settingsChanged(change);
|
settingsChanged(change);
|
||||||
});
|
}, system->lifetime());
|
||||||
}
|
}
|
||||||
|
|
||||||
Manager::QueuedNotification::QueuedNotification(
|
Manager::QueuedNotification::QueuedNotification(
|
||||||
|
|
|
@ -38,7 +38,7 @@ class HideAllButton;
|
||||||
class Manager;
|
class Manager;
|
||||||
std::unique_ptr<Manager> Create(System *system);
|
std::unique_ptr<Manager> Create(System *system);
|
||||||
|
|
||||||
class Manager final : public Notifications::Manager, private base::Subscriber {
|
class Manager final : public Notifications::Manager {
|
||||||
public:
|
public:
|
||||||
Manager(System *system);
|
Manager(System *system);
|
||||||
~Manager();
|
~Manager();
|
||||||
|
|
Loading…
Reference in New Issue