2
0
mirror of https://github.com/kotatogram/kotatogram-desktop synced 2025-08-31 14:45:14 +00:00

Don't always restart connection on config change.

This commit is contained in:
John Preston
2019-11-27 13:41:17 +03:00
parent e6c86b19db
commit 06f5f7f7d9
7 changed files with 50 additions and 36 deletions

View File

@@ -399,14 +399,18 @@ void Application::badMtprotoConfigurationError() {
void Application::startLocalStorage() {
Local::start();
subscribe(_dcOptions->changed(), [this](const MTP::DcOptions::Ids &ids) {
Local::writeSettings();
if (const auto instance = activeAccount().mtp()) {
for (const auto id : ids) {
instance->restart(id);
}
}
});
const auto writing = _lifetime.make_state<bool>(false);
_dcOptions->changed(
) | rpl::filter([=] {
return !*writing;
}) | rpl::start_with_next([=] {
*writing = true;
Ui::PostponeCall(this, [=] {
Local::writeSettings();
});
}, _lifetime);
_saveSettingsTimer.setCallback([=] { Local::writeSettings(); });
}