mirror of
https://hubproxy.babadafafafafa.cn/https://github.com/telegramdesktop/tdesktop
synced 2026-09-20 08:03:45 +08:00
Use new base::option::changes in a few old options
This commit is contained in:
@@ -47,7 +47,6 @@ base::options::toggle OptionDeadlockDetector({
|
||||
.id = kOptionDeadlockDetector,
|
||||
.name = "Deadlock Detector",
|
||||
.description = "Check once every 30 seconds that main thread is still responsive.",
|
||||
.restartRequired = true,
|
||||
});
|
||||
|
||||
} // namespace
|
||||
@@ -200,10 +199,16 @@ void Sandbox::launchApplication() {
|
||||
}
|
||||
setupScreenScale();
|
||||
|
||||
if (OptionDeadlockDetector.value()) {
|
||||
rpl::single(
|
||||
rpl::empty
|
||||
) | rpl::then(
|
||||
OptionDeadlockDetector.changes()
|
||||
) | rpl::on_next([=] {
|
||||
using DeadlockDetector::PingThread;
|
||||
_deadlockDetector = std::make_unique<PingThread>(this);
|
||||
}
|
||||
_deadlockDetector = OptionDeadlockDetector.value()
|
||||
? std::make_unique<PingThread>(this)
|
||||
: nullptr;
|
||||
}, _lifetime);
|
||||
|
||||
_application = std::make_unique<Application>();
|
||||
|
||||
|
||||
@@ -135,6 +135,8 @@ private:
|
||||
|
||||
std::unique_ptr<QThread> _deadlockDetector;
|
||||
|
||||
rpl::lifetime _lifetime;
|
||||
|
||||
};
|
||||
|
||||
} // namespace Core
|
||||
|
||||
@@ -332,9 +332,7 @@ void Create(Window::Notifications::System *system) {
|
||||
|
||||
Manager::Private::Private(not_null<Manager*> manager)
|
||||
: _manager(manager)
|
||||
, _application(UseGNotification()
|
||||
? Gio::Application::get_default()
|
||||
: nullptr)
|
||||
, _application(Gio::Application::get_default())
|
||||
, _sounds(cWorkingDir() + u"tdata/audio_cache"_q) {
|
||||
const auto &serverInformation = CurrentServerInformation;
|
||||
|
||||
@@ -429,7 +427,7 @@ void Manager::Private::init(XdgNotifications::NotificationsProxy proxy) {
|
||||
_proxy = proxy;
|
||||
_interface = proxy;
|
||||
|
||||
if (_application || !_interface) {
|
||||
if (!_interface) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -535,7 +533,7 @@ void Manager::Private::showNotification(
|
||||
.contextId = key,
|
||||
.msgId = info.itemId,
|
||||
};
|
||||
auto notification = _application
|
||||
auto notification = UseGNotification()
|
||||
? Gio::Notification::new_(info.title.toStdString())
|
||||
: Gio::Notification();
|
||||
|
||||
|
||||
@@ -149,7 +149,6 @@ base::options::toggle OptionCustomNotification({
|
||||
.scope = [] {
|
||||
return Platform::Notifications::Enforced();
|
||||
},
|
||||
.restartRequired = true,
|
||||
});
|
||||
|
||||
const char kOptionGNotification[] = "gnotification";
|
||||
@@ -168,7 +167,6 @@ base::options::toggle OptionGNotification({
|
||||
return false;
|
||||
#endif // __has_include(<gio/gio.hpp>)
|
||||
},
|
||||
.restartRequired = true,
|
||||
});
|
||||
|
||||
base::options::toggle HideReplyButtonOption({
|
||||
@@ -211,6 +209,13 @@ System::System()
|
||||
Core::App().domain().notifyUnreadBadgeChanged();
|
||||
}
|
||||
}, lifetime());
|
||||
|
||||
rpl::merge(
|
||||
OptionCustomNotification.changes(),
|
||||
OptionGNotification.changes()
|
||||
) | rpl::on_next([=] {
|
||||
createManager();
|
||||
}, lifetime());
|
||||
}
|
||||
|
||||
void System::createManager() {
|
||||
|
||||
Reference in New Issue
Block a user