aboutsummaryrefslogtreecommitdiffstats
path: root/packages/shared/src/stores
diff options
context:
space:
mode:
Diffstat (limited to 'packages/shared/src/stores')
-rw-r--r--packages/shared/src/stores/GlobalSettings.ts18
-rw-r--r--packages/shared/src/stores/Profile.ts14
-rw-r--r--packages/shared/src/stores/ProfileSettings.ts14
-rw-r--r--packages/shared/src/stores/Service.ts14
-rw-r--r--packages/shared/src/stores/ServiceSettings.ts18
-rw-r--r--packages/shared/src/stores/SharedStore.ts34
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
21import { Instance, types, SnapshotIn, SnapshotOut } from 'mobx-state-tree'; 21import { Instance, types, SnapshotIn, SnapshotOut } from 'mobx-state-tree';
22 22
23import { themeSource } from '../schemas'; 23import { ThemeSource } from '../schemas';
24 24
25export const globalSettings = types.model('GlobalSettings', { 25const 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
29export 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*/
33interface GlobalSettings extends Instance<typeof GlobalSettings> {}
34
35export default GlobalSettings;
30 36
31export interface GlobalSettingsSnapshotIn 37export interface GlobalSettingsSnapshotIn
32 extends SnapshotIn<typeof globalSettings> {} 38 extends SnapshotIn<typeof GlobalSettings> {}
33 39
34export interface GlobalSettingsSnapshotOut 40export 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
21import { Instance, types } from 'mobx-state-tree'; 21import { Instance, types } from 'mobx-state-tree';
22 22
23import { profileSettings } from './ProfileSettings'; 23import ProfileSettings from './ProfileSettings';
24 24
25export const profile = types.model('Profile', { 25const Profile = types.model('Profile', {
26 id: types.identifier, 26 id: types.identifier,
27 settings: profileSettings, 27 settings: ProfileSettings,
28}); 28});
29 29
30export 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*/
34interface Profile extends Instance<typeof Profile> {}
35
36export 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
21import { Instance, types, SnapshotIn, SnapshotOut } from 'mobx-state-tree'; 21import { Instance, types, SnapshotIn, SnapshotOut } from 'mobx-state-tree';
22 22
23export const profileSettings = types.model('ProfileSettings', { 23const ProfileSettings = types.model('ProfileSettings', {
24 name: types.string, 24 name: types.string,
25}); 25});
26 26
27export 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*/
31interface ProfileSettings extends Instance<typeof ProfileSettings> {}
32
33export default ProfileSettings;
28 34
29export interface ProfileSettingsSnapshotIn 35export interface ProfileSettingsSnapshotIn
30 extends SnapshotIn<typeof profileSettings> {} 36 extends SnapshotIn<typeof ProfileSettings> {}
31 37
32export interface ProfileSettingsSnapshotOut 38export 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
21import { Instance, types } from 'mobx-state-tree'; 21import { Instance, types } from 'mobx-state-tree';
22 22
23import { serviceSettings } from './ServiceSettings'; 23import ServiceSettings from './ServiceSettings';
24 24
25export const service = types.model('Service', { 25const 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
40export 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*/
44interface Service extends Instance<typeof Service> {}
45
46export 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
21import { Instance, types, SnapshotIn, SnapshotOut } from 'mobx-state-tree'; 21import { Instance, types, SnapshotIn, SnapshotOut } from 'mobx-state-tree';
22 22
23import { profile } from './Profile'; 23import Profile from './Profile';
24 24
25export const serviceSettings = types.model('ServiceSettings', { 25const 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
32export 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*/
36interface ServiceSettings extends Instance<typeof ServiceSettings> {}
37
38export default ServiceSettings;
33 39
34export interface ServiceSettingsSnapshotIn 40export interface ServiceSettingsSnapshotIn
35 extends SnapshotIn<typeof serviceSettings> {} 41 extends SnapshotIn<typeof ServiceSettings> {}
36 42
37export interface ServiceSettingsSnapshotOut 43export 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
29import { globalSettings } from './GlobalSettings'; 29import GlobalSettings from './GlobalSettings';
30import { profile } from './Profile'; 30import Profile from './Profile';
31import { service } from './Service'; 31import Service from './Service';
32 32
33export const sharedStore = types.model('SharedStore', { 33const 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
43export 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*/
47interface SharedStore extends Instance<typeof SharedStore> {}
48
49export default SharedStore;
44 50
45export interface SharedStoreSnapshotIn extends SnapshotIn<typeof sharedStore> {} 51export interface SharedStoreSnapshotIn extends SnapshotIn<typeof SharedStore> {}
46 52
47export interface SharedStoreSnapshotOut 53export interface SharedStoreSnapshotOut
48 extends SnapshotOut<typeof sharedStore> {} 54 extends SnapshotOut<typeof SharedStore> {}
49 55
50export interface SharedStoreListener { 56export interface SharedStoreListener {
51 onSnapshot(snapshot: SharedStoreSnapshotIn): void; 57 onSnapshot(snapshot: SharedStoreSnapshotIn): void;