2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-09-05 00:46:08 +00:00

Allow editing general notification sound.

This commit is contained in:
John Preston
2022-04-06 19:23:41 +04:00
parent c71ba2b8e7
commit 0615f21deb
11 changed files with 210 additions and 102 deletions

View File

@@ -1763,6 +1763,11 @@ void ApiWrap::updateNotifySettingsDelayed(not_null<const PeerData*> peer) {
_updateNotifySettingsTimer.callOnce(kNotifySettingSaveTimeout);
}
void ApiWrap::updateDefaultNotifySettingsDelayed(Data::DefaultNotify type) {
_updateNotifySettingsDefaults.emplace(type);
_updateNotifySettingsTimer.callOnce(kNotifySettingSaveTimeout);
}
void ApiWrap::sendNotifySettingsUpdates() {
while (!_updateNotifySettingsPeers.empty()) {
const auto peer = *_updateNotifySettingsPeers.begin();
@@ -1772,6 +1777,25 @@ void ApiWrap::sendNotifySettingsUpdates() {
peer->notifySerialize()
)).afterDelay(_updateNotifySettingsPeers.empty() ? 0 : 10).send();
}
const auto &settings = session().data().notifySettings();
while (!_updateNotifySettingsDefaults.empty()) {
const auto type = *_updateNotifySettingsDefaults.begin();
_updateNotifySettingsDefaults.erase(
_updateNotifySettingsDefaults.begin());
const auto input = [&] {
switch (type) {
case Data::DefaultNotify::User: return MTP_inputNotifyUsers();
case Data::DefaultNotify::Group: return MTP_inputNotifyChats();
case Data::DefaultNotify::Broadcast:
return MTP_inputNotifyBroadcasts();
}
Unexpected("Default notify type in sendNotifySettingsUpdates");
}();
request(MTPaccount_UpdateNotifySettings(
input,
settings.defaultSettings(type).serialize()
)).afterDelay(_updateNotifySettingsDefaults.empty() ? 0 : 10).send();
}
}
void ApiWrap::saveDraftToCloudDelayed(not_null<History*> history) {