diff --git a/src/store/index.tsx b/src/store/index.tsx index 813cfb9..694b9ce 100644 --- a/src/store/index.tsx +++ b/src/store/index.tsx @@ -7,6 +7,15 @@ import { sendMainMessage } from '../shared/utils'; import MessageSound from '../assets/sound.mp3'; +interface StoreSettings { + name: string; + avatar: string; + color: string; + url: string; + enableNotificationTooltip: boolean; + enableNotificationSound: boolean; + isDarkTheme: boolean; +} class RootStore { constructor() { makeAutoObservable(this); @@ -82,7 +91,7 @@ class RootStore { isMinimized = false; - settings = { + settings: StoreSettings = { name: '', avatar: '', color: '#4F4F4F', @@ -94,6 +103,13 @@ class RootStore { notifications = []; + setSetting(key: keyof StoreSettings, value: string | boolean) { + this.settings = { + ...this.settings, + [key]: value, + }; + } + setIsMinimized(isMinimized: boolean) { this.isMinimized = isMinimized; } diff --git a/src/views/Settings/index.tsx b/src/views/Settings/index.tsx index c1c5ed0..3950526 100644 --- a/src/views/Settings/index.tsx +++ b/src/views/Settings/index.tsx @@ -185,8 +185,10 @@ const SettingsView: FunctionComponent = observer(() => { name="bell" ref={ref} onClick={() => { - store.settings.enableNotificationSound = !store.settings - .enableNotificationSound; + store.setSetting( + 'enableNotificationSound', + !store.settings.enableNotificationSound + ); saveSettings(false); }} >