mirror of
https://github.com/cinnyapp/cinny.git
synced 2025-11-05 06:50:28 +03:00
Fix unread reset and notification settings (#1824)
* reset unread with client sync state change * fix notification toggle setting not working * revert formatOnSave vscode setting
This commit is contained in:
parent
e2228a18c1
commit
e6d6b0349e
9 changed files with 62 additions and 100 deletions
|
|
@ -52,8 +52,6 @@ const cons = {
|
|||
TOGGLE_PEOPLE_DRAWER: 'TOGGLE_PEOPLE_DRAWER',
|
||||
TOGGLE_MEMBERSHIP_EVENT: 'TOGGLE_MEMBERSHIP_EVENT',
|
||||
TOGGLE_NICKAVATAR_EVENT: 'TOGGLE_NICKAVATAR_EVENT',
|
||||
TOGGLE_NOTIFICATIONS: 'TOGGLE_NOTIFICATIONS',
|
||||
TOGGLE_NOTIFICATION_SOUNDS: 'TOGGLE_NOTIFICATION_SOUNDS',
|
||||
},
|
||||
},
|
||||
events: {
|
||||
|
|
@ -81,8 +79,6 @@ const cons = {
|
|||
PEOPLE_DRAWER_TOGGLED: 'PEOPLE_DRAWER_TOGGLED',
|
||||
MEMBERSHIP_EVENTS_TOGGLED: 'MEMBERSHIP_EVENTS_TOGGLED',
|
||||
NICKAVATAR_EVENTS_TOGGLED: 'NICKAVATAR_EVENTS_TOGGLED',
|
||||
NOTIFICATIONS_TOGGLED: 'NOTIFICATIONS_TOGGLED',
|
||||
NOTIFICATION_SOUNDS_TOGGLED: 'NOTIFICATION_SOUNDS_TOGGLED',
|
||||
},
|
||||
},
|
||||
};
|
||||
|
|
|
|||
|
|
@ -33,8 +33,6 @@ class Settings extends EventEmitter {
|
|||
this.isPeopleDrawer = this.getIsPeopleDrawer();
|
||||
this.hideMembershipEvents = this.getHideMembershipEvents();
|
||||
this.hideNickAvatarEvents = this.getHideNickAvatarEvents();
|
||||
this._showNotifications = this.getShowNotifications();
|
||||
this.isNotificationSounds = this.getIsNotificationSounds();
|
||||
|
||||
this.darkModeQueryList = window.matchMedia('(prefers-color-scheme: dark)');
|
||||
|
||||
|
|
@ -137,29 +135,6 @@ class Settings extends EventEmitter {
|
|||
return settings.isPeopleDrawer;
|
||||
}
|
||||
|
||||
get showNotifications() {
|
||||
if (window.Notification?.permission !== 'granted') return false;
|
||||
return this._showNotifications;
|
||||
}
|
||||
|
||||
getShowNotifications() {
|
||||
if (typeof this._showNotifications === 'boolean') return this._showNotifications;
|
||||
|
||||
const settings = getSettings();
|
||||
if (settings === null) return true;
|
||||
if (typeof settings.showNotifications === 'undefined') return true;
|
||||
return settings.showNotifications;
|
||||
}
|
||||
|
||||
getIsNotificationSounds() {
|
||||
if (typeof this.isNotificationSounds === 'boolean') return this.isNotificationSounds;
|
||||
|
||||
const settings = getSettings();
|
||||
if (settings === null) return true;
|
||||
if (typeof settings.isNotificationSounds === 'undefined') return true;
|
||||
return settings.isNotificationSounds;
|
||||
}
|
||||
|
||||
setter(action) {
|
||||
const actions = {
|
||||
[cons.actions.settings.TOGGLE_SYSTEM_THEME]: () => {
|
||||
|
|
@ -185,20 +160,6 @@ class Settings extends EventEmitter {
|
|||
setSettings('hideNickAvatarEvents', this.hideNickAvatarEvents);
|
||||
this.emit(cons.events.settings.NICKAVATAR_EVENTS_TOGGLED, this.hideNickAvatarEvents);
|
||||
},
|
||||
[cons.actions.settings.TOGGLE_NOTIFICATIONS]: async () => {
|
||||
if (window.Notification?.permission !== 'granted') {
|
||||
this._showNotifications = false;
|
||||
} else {
|
||||
this._showNotifications = !this._showNotifications;
|
||||
}
|
||||
setSettings('showNotifications', this._showNotifications);
|
||||
this.emit(cons.events.settings.NOTIFICATIONS_TOGGLED, this._showNotifications);
|
||||
},
|
||||
[cons.actions.settings.TOGGLE_NOTIFICATION_SOUNDS]: () => {
|
||||
this.isNotificationSounds = !this.isNotificationSounds;
|
||||
setSettings('isNotificationSounds', this.isNotificationSounds);
|
||||
this.emit(cons.events.settings.NOTIFICATION_SOUNDS_TOGGLED, this.isNotificationSounds);
|
||||
},
|
||||
};
|
||||
|
||||
actions[action.type]?.();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue