diff options
Diffstat (limited to 'packages/main/src/stores/RuntimeService.ts')
-rw-r--r-- | packages/main/src/stores/RuntimeService.ts | 74 |
1 files changed, 0 insertions, 74 deletions
diff --git a/packages/main/src/stores/RuntimeService.ts b/packages/main/src/stores/RuntimeService.ts deleted file mode 100644 index ecb1942..0000000 --- a/packages/main/src/stores/RuntimeService.ts +++ /dev/null | |||
@@ -1,74 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2022 Kristóf Marussy <kristof@marussy.com> | ||
3 | * | ||
4 | * This file is part of Sophie. | ||
5 | * | ||
6 | * Sophie is free software: you can redistribute it and/or modify | ||
7 | * it under the terms of the GNU Affero General Public License as | ||
8 | * published by the Free Software Foundation, version 3. | ||
9 | * | ||
10 | * This program is distributed in the hope that it will be useful, | ||
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | * GNU Affero General Public License for more details. | ||
14 | * | ||
15 | * You should have received a copy of the GNU Affero General Public License | ||
16 | * along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
17 | * | ||
18 | * SPDX-License-Identifier: AGPL-3.0-only | ||
19 | */ | ||
20 | |||
21 | import { UnreadCount } from '@sophie/service-shared'; | ||
22 | import { runtimeService as originalRuntimeService } from '@sophie/shared'; | ||
23 | import { Instance } from 'mobx-state-tree'; | ||
24 | |||
25 | export const runtimeService = originalRuntimeService.actions((self) => ({ | ||
26 | setLocation({ | ||
27 | url, | ||
28 | canGoBack, | ||
29 | canGoForward, | ||
30 | }: { | ||
31 | url: string; | ||
32 | canGoBack: boolean; | ||
33 | canGoForward: boolean; | ||
34 | }): void { | ||
35 | self.url = url; | ||
36 | self.canGoBack = canGoBack; | ||
37 | self.canGoForward = canGoForward; | ||
38 | }, | ||
39 | setTitle(title: string): void { | ||
40 | self.title = title; | ||
41 | }, | ||
42 | hibernated(): void { | ||
43 | self.canGoBack = false; | ||
44 | self.canGoForward = false; | ||
45 | self.state = 'hibernated'; | ||
46 | }, | ||
47 | startedLoading(): void { | ||
48 | self.state = 'loading'; | ||
49 | }, | ||
50 | finishedLoading(): void { | ||
51 | if (self.state === 'loading') { | ||
52 | // Do not overwrite crashed state if the service haven't been reloaded yet. | ||
53 | self.state = 'loaded'; | ||
54 | } | ||
55 | }, | ||
56 | crashed(): void { | ||
57 | self.state = 'crashed'; | ||
58 | }, | ||
59 | setUnreadCount({ direct, indirect }: UnreadCount): void { | ||
60 | if (direct !== undefined) { | ||
61 | self.directMessageCount = direct; | ||
62 | } | ||
63 | if (indirect !== undefined) { | ||
64 | self.indirectMessageCount = indirect; | ||
65 | } | ||
66 | }, | ||
67 | })); | ||
68 | |||
69 | export interface RuntimeService extends Instance<typeof runtimeService> {} | ||
70 | |||
71 | export type { | ||
72 | RuntimeServiceSnapshotIn, | ||
73 | RuntimeServiceSnapshotOut, | ||
74 | } from '@sophie/shared'; | ||