diff options
Diffstat (limited to 'packages/main/src/reactions/loadServices.ts')
-rw-r--r-- | packages/main/src/reactions/loadServices.ts | 65 |
1 files changed, 26 insertions, 39 deletions
diff --git a/packages/main/src/reactions/loadServices.ts b/packages/main/src/reactions/loadServices.ts index 533ef95..1325a36 100644 --- a/packages/main/src/reactions/loadServices.ts +++ b/packages/main/src/reactions/loadServices.ts | |||
@@ -18,7 +18,7 @@ | |||
18 | * SPDX-License-Identifier: AGPL-3.0-only | 18 | * SPDX-License-Identifier: AGPL-3.0-only |
19 | */ | 19 | */ |
20 | 20 | ||
21 | import { autorun, reaction } from 'mobx'; | 21 | import { reaction } from 'mobx'; |
22 | import { addDisposer } from 'mobx-state-tree'; | 22 | import { addDisposer } from 'mobx-state-tree'; |
23 | 23 | ||
24 | import type { | 24 | import type { |
@@ -26,10 +26,10 @@ import type { | |||
26 | Partition, | 26 | Partition, |
27 | ServiceView, | 27 | ServiceView, |
28 | ViewFactory, | 28 | ViewFactory, |
29 | } from '../infrastructure/electron/types'; | 29 | } from '../infrastructure/electron/types.js'; |
30 | import type MainStore from '../stores/MainStore'; | 30 | import type MainStore from '../stores/MainStore.js'; |
31 | import type Service from '../stores/Service'; | 31 | import type Service from '../stores/Service.js'; |
32 | import { getLogger } from '../utils/log'; | 32 | import getLogger from '../utils/getLogger.js'; |
33 | 33 | ||
34 | const log = getLogger('loadServices'); | 34 | const log = getLogger('loadServices'); |
35 | 35 | ||
@@ -78,36 +78,28 @@ export default function loadServices( | |||
78 | 78 | ||
79 | const viewsToDispose = new Map(servicesToViews); | 79 | const viewsToDispose = new Map(servicesToViews); |
80 | servicesById.forEach((service, serviceId) => { | 80 | servicesById.forEach((service, serviceId) => { |
81 | if (service.shouldBeLoaded) { | 81 | if (!service.shouldBeLoaded) { |
82 | let view = servicesToViews.get(serviceId); | 82 | return; |
83 | const { | 83 | } |
84 | settings: { | 84 | let view = servicesToViews.get(serviceId); |
85 | profile: { id: profileId }, | 85 | const { |
86 | }, | 86 | settings: { |
87 | } = service; | 87 | profile: { id: profileId }, |
88 | if (view === undefined || view.partitionId !== profileId) { | 88 | }, |
89 | log.debug('Creating view for service', serviceId); | 89 | } = service; |
90 | const partition = profilesToPartitions.get(profileId); | 90 | if (view === undefined || view.partitionId !== profileId) { |
91 | if (partition === undefined) { | 91 | log.debug('Creating view for service', serviceId); |
92 | throw new Error(`Missing Partition ${profileId}`); | 92 | const partition = profilesToPartitions.get(profileId); |
93 | } | 93 | if (partition === undefined) { |
94 | view = viewFactory.createServiceView(service, partition); | 94 | throw new Error(`Missing Partition ${profileId}`); |
95 | view.setBounds(store.browserViewBounds); | ||
96 | servicesToViews.set(serviceId, view); | ||
97 | service.setServiceView(view); | ||
98 | const { urlToLoad } = service; | ||
99 | view.loadURL(urlToLoad).catch((error) => { | ||
100 | log.warn( | ||
101 | 'Cannot URL', | ||
102 | urlToLoad, | ||
103 | 'for service', | ||
104 | serviceId, | ||
105 | error, | ||
106 | ); | ||
107 | }); | ||
108 | } else { | ||
109 | viewsToDispose.delete(serviceId); | ||
110 | } | 95 | } |
96 | view = viewFactory.createServiceView(service, partition); | ||
97 | servicesToViews.set(serviceId, view); | ||
98 | service.setServiceView(view); | ||
99 | const { urlToLoad } = service; | ||
100 | view.loadURL(urlToLoad); | ||
101 | } else { | ||
102 | viewsToDispose.delete(serviceId); | ||
111 | } | 103 | } |
112 | }); | 104 | }); |
113 | 105 | ||
@@ -140,12 +132,7 @@ export default function loadServices( | |||
140 | }, | 132 | }, |
141 | ); | 133 | ); |
142 | 134 | ||
143 | const resizeDisposer = autorun(() => { | ||
144 | store.visibleService?.serviceView?.setBounds(store.browserViewBounds); | ||
145 | }); | ||
146 | |||
147 | addDisposer(store, () => { | 135 | addDisposer(store, () => { |
148 | resizeDisposer(); | ||
149 | disposer(); | 136 | disposer(); |
150 | store.mainWindow?.setServiceView(undefined); | 137 | store.mainWindow?.setServiceView(undefined); |
151 | servicesToViews.forEach((serviceView, serviceId) => { | 138 | servicesToViews.forEach((serviceView, serviceId) => { |