diff options
Diffstat (limited to 'packages/shared/src/stores')
-rw-r--r-- | packages/shared/src/stores/GlobalSettings.ts | 18 | ||||
-rw-r--r-- | packages/shared/src/stores/Profile.ts | 14 | ||||
-rw-r--r-- | packages/shared/src/stores/ProfileSettings.ts | 14 | ||||
-rw-r--r-- | packages/shared/src/stores/Service.ts | 14 | ||||
-rw-r--r-- | packages/shared/src/stores/ServiceSettings.ts | 18 | ||||
-rw-r--r-- | packages/shared/src/stores/SharedStore.ts | 34 |
6 files changed, 74 insertions, 38 deletions
diff --git a/packages/shared/src/stores/GlobalSettings.ts b/packages/shared/src/stores/GlobalSettings.ts index bd0155a..3a813b8 100644 --- a/packages/shared/src/stores/GlobalSettings.ts +++ b/packages/shared/src/stores/GlobalSettings.ts | |||
@@ -20,16 +20,22 @@ | |||
20 | 20 | ||
21 | import { Instance, types, SnapshotIn, SnapshotOut } from 'mobx-state-tree'; | 21 | import { Instance, types, SnapshotIn, SnapshotOut } from 'mobx-state-tree'; |
22 | 22 | ||
23 | import { themeSource } from '../schemas'; | 23 | import { ThemeSource } from '../schemas'; |
24 | 24 | ||
25 | export const globalSettings = types.model('GlobalSettings', { | 25 | const GlobalSettings = types.model('GlobalSettings', { |
26 | themeSource: types.optional(types.enumeration(themeSource.options), 'system'), | 26 | themeSource: types.optional(types.enumeration(ThemeSource.options), 'system'), |
27 | }); | 27 | }); |
28 | 28 | ||
29 | export interface GlobalSettings extends Instance<typeof globalSettings> {} | 29 | /* |
30 | eslint-disable-next-line @typescript-eslint/no-redeclare -- | ||
31 | Intentionally naming the type the same as the store definition. | ||
32 | */ | ||
33 | interface GlobalSettings extends Instance<typeof GlobalSettings> {} | ||
34 | |||
35 | export default GlobalSettings; | ||
30 | 36 | ||
31 | export interface GlobalSettingsSnapshotIn | 37 | export interface GlobalSettingsSnapshotIn |
32 | extends SnapshotIn<typeof globalSettings> {} | 38 | extends SnapshotIn<typeof GlobalSettings> {} |
33 | 39 | ||
34 | export interface GlobalSettingsSnapshotOut | 40 | export interface GlobalSettingsSnapshotOut |
35 | extends SnapshotOut<typeof globalSettings> {} | 41 | extends SnapshotOut<typeof GlobalSettings> {} |
diff --git a/packages/shared/src/stores/Profile.ts b/packages/shared/src/stores/Profile.ts index bb058f6..256c33e 100644 --- a/packages/shared/src/stores/Profile.ts +++ b/packages/shared/src/stores/Profile.ts | |||
@@ -20,11 +20,17 @@ | |||
20 | 20 | ||
21 | import { Instance, types } from 'mobx-state-tree'; | 21 | import { Instance, types } from 'mobx-state-tree'; |
22 | 22 | ||
23 | import { profileSettings } from './ProfileSettings'; | 23 | import ProfileSettings from './ProfileSettings'; |
24 | 24 | ||
25 | export const profile = types.model('Profile', { | 25 | const Profile = types.model('Profile', { |
26 | id: types.identifier, | 26 | id: types.identifier, |
27 | settings: profileSettings, | 27 | settings: ProfileSettings, |
28 | }); | 28 | }); |
29 | 29 | ||
30 | export interface Profile extends Instance<typeof profile> {} | 30 | /* |
31 | eslint-disable-next-line @typescript-eslint/no-redeclare -- | ||
32 | Intentionally naming the type the same as the store definition. | ||
33 | */ | ||
34 | interface Profile extends Instance<typeof Profile> {} | ||
35 | |||
36 | export default Profile; | ||
diff --git a/packages/shared/src/stores/ProfileSettings.ts b/packages/shared/src/stores/ProfileSettings.ts index ec8da5f..9f2b27c 100644 --- a/packages/shared/src/stores/ProfileSettings.ts +++ b/packages/shared/src/stores/ProfileSettings.ts | |||
@@ -20,14 +20,20 @@ | |||
20 | 20 | ||
21 | import { Instance, types, SnapshotIn, SnapshotOut } from 'mobx-state-tree'; | 21 | import { Instance, types, SnapshotIn, SnapshotOut } from 'mobx-state-tree'; |
22 | 22 | ||
23 | export const profileSettings = types.model('ProfileSettings', { | 23 | const ProfileSettings = types.model('ProfileSettings', { |
24 | name: types.string, | 24 | name: types.string, |
25 | }); | 25 | }); |
26 | 26 | ||
27 | export interface ProfileSettings extends Instance<typeof profileSettings> {} | 27 | /* |
28 | eslint-disable-next-line @typescript-eslint/no-redeclare -- | ||
29 | Intentionally naming the type the same as the store definition. | ||
30 | */ | ||
31 | interface ProfileSettings extends Instance<typeof ProfileSettings> {} | ||
32 | |||
33 | export default ProfileSettings; | ||
28 | 34 | ||
29 | export interface ProfileSettingsSnapshotIn | 35 | export interface ProfileSettingsSnapshotIn |
30 | extends SnapshotIn<typeof profileSettings> {} | 36 | extends SnapshotIn<typeof ProfileSettings> {} |
31 | 37 | ||
32 | export interface ProfileSettingsSnapshotOut | 38 | export interface ProfileSettingsSnapshotOut |
33 | extends SnapshotOut<typeof profileSettings> {} | 39 | extends SnapshotOut<typeof ProfileSettings> {} |
diff --git a/packages/shared/src/stores/Service.ts b/packages/shared/src/stores/Service.ts index 36acd3d..4a7334d 100644 --- a/packages/shared/src/stores/Service.ts +++ b/packages/shared/src/stores/Service.ts | |||
@@ -20,11 +20,11 @@ | |||
20 | 20 | ||
21 | import { Instance, types } from 'mobx-state-tree'; | 21 | import { Instance, types } from 'mobx-state-tree'; |
22 | 22 | ||
23 | import { serviceSettings } from './ServiceSettings'; | 23 | import ServiceSettings from './ServiceSettings'; |
24 | 24 | ||
25 | export const service = types.model('Service', { | 25 | const Service = types.model('Service', { |
26 | id: types.identifier, | 26 | id: types.identifier, |
27 | settings: serviceSettings, | 27 | settings: ServiceSettings, |
28 | currentUrl: types.maybe(types.string), | 28 | currentUrl: types.maybe(types.string), |
29 | canGoBack: false, | 29 | canGoBack: false, |
30 | canGoForward: false, | 30 | canGoForward: false, |
@@ -37,4 +37,10 @@ export const service = types.model('Service', { | |||
37 | indirectMessageCount: 0, | 37 | indirectMessageCount: 0, |
38 | }); | 38 | }); |
39 | 39 | ||
40 | export interface Service extends Instance<typeof service> {} | 40 | /* |
41 | eslint-disable-next-line @typescript-eslint/no-redeclare -- | ||
42 | Intentionally naming the type the same as the store definition. | ||
43 | */ | ||
44 | interface Service extends Instance<typeof Service> {} | ||
45 | |||
46 | export default Service; | ||
diff --git a/packages/shared/src/stores/ServiceSettings.ts b/packages/shared/src/stores/ServiceSettings.ts index 54cd7eb..6ba1dfa 100644 --- a/packages/shared/src/stores/ServiceSettings.ts +++ b/packages/shared/src/stores/ServiceSettings.ts | |||
@@ -20,19 +20,25 @@ | |||
20 | 20 | ||
21 | import { Instance, types, SnapshotIn, SnapshotOut } from 'mobx-state-tree'; | 21 | import { Instance, types, SnapshotIn, SnapshotOut } from 'mobx-state-tree'; |
22 | 22 | ||
23 | import { profile } from './Profile'; | 23 | import Profile from './Profile'; |
24 | 24 | ||
25 | export const serviceSettings = types.model('ServiceSettings', { | 25 | const ServiceSettings = types.model('ServiceSettings', { |
26 | name: types.string, | 26 | name: types.string, |
27 | profile: types.reference(profile), | 27 | profile: types.reference(Profile), |
28 | // TODO: Remove this once recipes are added. | 28 | // TODO: Remove this once recipes are added. |
29 | url: types.string, | 29 | url: types.string, |
30 | }); | 30 | }); |
31 | 31 | ||
32 | export interface ServiceSettings extends Instance<typeof serviceSettings> {} | 32 | /* |
33 | eslint-disable-next-line @typescript-eslint/no-redeclare -- | ||
34 | Intentionally naming the type the same as the store definition. | ||
35 | */ | ||
36 | interface ServiceSettings extends Instance<typeof ServiceSettings> {} | ||
37 | |||
38 | export default ServiceSettings; | ||
33 | 39 | ||
34 | export interface ServiceSettingsSnapshotIn | 40 | export interface ServiceSettingsSnapshotIn |
35 | extends SnapshotIn<typeof serviceSettings> {} | 41 | extends SnapshotIn<typeof ServiceSettings> {} |
36 | 42 | ||
37 | export interface ServiceSettingsSnapshotOut | 43 | export interface ServiceSettingsSnapshotOut |
38 | extends SnapshotOut<typeof serviceSettings> {} | 44 | extends SnapshotOut<typeof ServiceSettings> {} |
diff --git a/packages/shared/src/stores/SharedStore.ts b/packages/shared/src/stores/SharedStore.ts index f301b9d..0cac3a5 100644 --- a/packages/shared/src/stores/SharedStore.ts +++ b/packages/shared/src/stores/SharedStore.ts | |||
@@ -26,26 +26,32 @@ import { | |||
26 | SnapshotOut, | 26 | SnapshotOut, |
27 | } from 'mobx-state-tree'; | 27 | } from 'mobx-state-tree'; |
28 | 28 | ||
29 | import { globalSettings } from './GlobalSettings'; | 29 | import GlobalSettings from './GlobalSettings'; |
30 | import { profile } from './Profile'; | 30 | import Profile from './Profile'; |
31 | import { service } from './Service'; | 31 | import Service from './Service'; |
32 | 32 | ||
33 | export const sharedStore = types.model('SharedStore', { | 33 | const SharedStore = types.model('SharedStore', { |
34 | settings: types.optional(globalSettings, {}), | 34 | settings: types.optional(GlobalSettings, {}), |
35 | profilesById: types.map(profile), | 35 | profilesById: types.map(Profile), |
36 | profiles: types.array(types.reference(profile)), | 36 | profiles: types.array(types.reference(Profile)), |
37 | servicesById: types.map(service), | 37 | servicesById: types.map(Service), |
38 | services: types.array(types.reference(service)), | 38 | services: types.array(types.reference(Service)), |
39 | selectedService: types.safeReference(service), | 39 | selectedService: types.safeReference(Service), |
40 | shouldUseDarkColors: false, | 40 | shouldUseDarkColors: false, |
41 | }); | 41 | }); |
42 | 42 | ||
43 | export interface SharedStore extends Instance<typeof sharedStore> {} | 43 | /* |
44 | eslint-disable-next-line @typescript-eslint/no-redeclare -- | ||
45 | Intentionally naming the type the same as the store definition. | ||
46 | */ | ||
47 | interface SharedStore extends Instance<typeof SharedStore> {} | ||
48 | |||
49 | export default SharedStore; | ||
44 | 50 | ||
45 | export interface SharedStoreSnapshotIn extends SnapshotIn<typeof sharedStore> {} | 51 | export interface SharedStoreSnapshotIn extends SnapshotIn<typeof SharedStore> {} |
46 | 52 | ||
47 | export interface SharedStoreSnapshotOut | 53 | export interface SharedStoreSnapshotOut |
48 | extends SnapshotOut<typeof sharedStore> {} | 54 | extends SnapshotOut<typeof SharedStore> {} |
49 | 55 | ||
50 | export interface SharedStoreListener { | 56 | export interface SharedStoreListener { |
51 | onSnapshot(snapshot: SharedStoreSnapshotIn): void; | 57 | onSnapshot(snapshot: SharedStoreSnapshotIn): void; |