diff options
author | Kristóf Marussy <kristof@marussy.com> | 2022-02-27 01:52:55 +0100 |
---|---|---|
committer | Kristóf Marussy <kristof@marussy.com> | 2022-03-06 18:56:47 +0100 |
commit | 098d6f9bb1fd26f2d192db497992ab95b258ce55 (patch) | |
tree | 22905f87e6ad53032b6ff39bb3af274df2f6287c /packages/renderer/src/stores/Service.ts | |
parent | refactor: Shared model type factories (diff) | |
download | sophie-098d6f9bb1fd26f2d192db497992ab95b258ce55.tar.gz sophie-098d6f9bb1fd26f2d192db497992ab95b258ce55.tar.zst sophie-098d6f9bb1fd26f2d192db497992ab95b258ce55.zip |
feat: Location bar actions
The buttons and the text field in the location bar shall now affect the
BrowserView of the loaded service.
Some error handling is still needed, e.g., when loading a web page fails
due to a DNS error.
Signed-off-by: Kristóf Marussy <kristof@marussy.com>
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 -- |