diff options
Diffstat (limited to 'packages/renderer/src/stores/Service.ts')
-rw-r--r-- | packages/renderer/src/stores/Service.ts | 46 |
1 files changed, 44 insertions, 2 deletions
diff --git a/packages/renderer/src/stores/Service.ts b/packages/renderer/src/stores/Service.ts index c2c938a..7878ea0 100644 --- a/packages/renderer/src/stores/Service.ts +++ b/packages/renderer/src/stores/Service.ts | |||
@@ -18,12 +18,54 @@ | |||
18 | * SPDX-License-Identifier: AGPL-3.0-only | 18 | * SPDX-License-Identifier: AGPL-3.0-only |
19 | */ | 19 | */ |
20 | 20 | ||
21 | import { defineServiceModel } from '@sophie/shared'; | 21 | import { defineServiceModel, ServiceAction } from '@sophie/shared'; |
22 | import { Instance } from 'mobx-state-tree'; | 22 | import { Instance } from 'mobx-state-tree'; |
23 | 23 | ||
24 | import getEnv from '../env/getEnv'; | ||
25 | |||
24 | import ServiceSettings from './ServiceSettings'; | 26 | import ServiceSettings from './ServiceSettings'; |
25 | 27 | ||
26 | const Service = defineServiceModel(ServiceSettings); | 28 | const Service = defineServiceModel(ServiceSettings).actions((self) => ({ |
29 | dispatch(serviceAction: ServiceAction): void { | ||
30 | getEnv(self).dispatchMainAction({ | ||
31 | action: 'dispatch-service-action', | ||
32 | serviceId: self.id, | ||
33 | serviceAction, | ||
34 | }); | ||
35 | }, | ||
36 | goBack(): void { | ||
37 | this.dispatch({ | ||
38 | action: 'back', | ||
39 | }); | ||
40 | }, | ||
41 | goForward(): void { | ||
42 | this.dispatch({ | ||
43 | action: 'forward', | ||
44 | }); | ||
45 | }, | ||
46 | reload(ignoreCache = false): void { | ||
47 | this.dispatch({ | ||
48 | action: 'reload', | ||
49 | ignoreCache, | ||
50 | }); | ||
51 | }, | ||
52 | stop(): void { | ||
53 | this.dispatch({ | ||
54 | action: 'stop', | ||
55 | }); | ||
56 | }, | ||
57 | go(url: string): void { | ||
58 | this.dispatch({ | ||
59 | action: 'go', | ||
60 | url, | ||
61 | }); | ||
62 | }, | ||
63 | goHome(): void { | ||
64 | this.dispatch({ | ||
65 | action: 'go-home', | ||
66 | }); | ||
67 | }, | ||
68 | })); | ||
27 | 69 | ||
28 | /* | 70 | /* |
29 | eslint-disable-next-line @typescript-eslint/no-redeclare -- | 71 | eslint-disable-next-line @typescript-eslint/no-redeclare -- |