diff --git a/src/lib/appManagers/appDialogsManager.ts b/src/lib/appManagers/appDialogsManager.ts index ac8cd52d..3a3f2974 100644 --- a/src/lib/appManagers/appDialogsManager.ts +++ b/src/lib/appManagers/appDialogsManager.ts @@ -56,10 +56,11 @@ import debounce from "../../helpers/schedulers/debounce"; import generateVerifiedIcon from "../../components/generateVerifiedIcon"; import { NULL_PEER_ID } from "../mtproto/mtproto_config"; import groupCallActiveIcon from "../../components/groupCallActiveIcon"; -import { Chat } from "../../layer"; +import { Chat, NotifyPeer } from "../../layer"; import IS_GROUP_CALL_SUPPORTED from "../../environment/groupCallSupport"; import mediaSizes from "../../helpers/mediaSizes"; import appNavigationController, { NavigationItem } from "../../components/appNavigationController"; +import assumeType from "../../helpers/assumeType"; export type DialogDom = { avatarEl: AvatarElement, @@ -579,6 +580,16 @@ export class AppDialogsManager { } private async onStateLoaded(state: State) { + if(state.notifySettings) { + for(const key in state.notifySettings) { + assumeType>(key); + appNotificationsManager.savePeerSettings({ + key, + settings: state.notifySettings[key] + }); + } + } + appNotificationsManager.getNotifyPeerTypeSettings(); if(!this.initedListeners) { diff --git a/src/lib/appManagers/appNotificationsManager.ts b/src/lib/appManagers/appNotificationsManager.ts index d3b3968e..025f7327 100644 --- a/src/lib/appManagers/appNotificationsManager.ts +++ b/src/lib/appManagers/appNotificationsManager.ts @@ -475,6 +475,11 @@ export class AppNotificationsManager { if(!peerId) { rootScope.dispatchEvent('notify_peer_type_settings', {key, settings}); + appStateManager.getState().then(state => { + const notifySettings = state.notifySettings; + notifySettings[key] = settings; + appStateManager.pushToState('notifySettings', notifySettings); + }); } else { this.checkMuteUntilThrottled(); } diff --git a/src/lib/appManagers/appStateManager.ts b/src/lib/appManagers/appStateManager.ts index 3d05a138..8ec0b986 100644 --- a/src/lib/appManagers/appStateManager.ts +++ b/src/lib/appManagers/appStateManager.ts @@ -18,7 +18,7 @@ import { copy, setDeepProperty, validateInitObject } from '../../helpers/object' import App from '../../config/app'; import DEBUG, { MOUNT_CLASS_TO } from '../../config/debug'; import AppStorage from '../storage'; -import { AutoDownloadSettings, Chat } from '../../layer'; +import { AutoDownloadSettings, Chat, NotifyPeer, PeerNotifySettings } from '../../layer'; import { IS_MOBILE } from '../../environment/userAgent'; import DATABASE_STATE from '../../config/databases/state'; import sessionStorage from '../sessionStorage'; @@ -114,7 +114,8 @@ export type State = { }, keepSigned: boolean, chatContextMenuHintWasShown: boolean, - stateId: number + stateId: number, + notifySettings: {[k in Exclude]?: PeerNotifySettings.peerNotifySettings} }; export const STATE_INIT: State = { @@ -207,7 +208,8 @@ export const STATE_INIT: State = { }, keepSigned: true, chatContextMenuHintWasShown: false, - stateId: nextRandomUint(32) + stateId: nextRandomUint(32), + notifySettings: {} }; const ALL_KEYS = Object.keys(STATE_INIT) as any as Array;