diff options
Diffstat (limited to 'packages/main/src/infrastructure')
-rw-r--r-- | packages/main/src/infrastructure/electron/impl/ElectronServiceView.ts | 36 | ||||
-rw-r--r-- | packages/main/src/infrastructure/electron/types.ts | 2 |
2 files changed, 31 insertions, 7 deletions
diff --git a/packages/main/src/infrastructure/electron/impl/ElectronServiceView.ts b/packages/main/src/infrastructure/electron/impl/ElectronServiceView.ts index e5fdf11..d90ff19 100644 --- a/packages/main/src/infrastructure/electron/impl/ElectronServiceView.ts +++ b/packages/main/src/infrastructure/electron/impl/ElectronServiceView.ts | |||
@@ -22,12 +22,15 @@ import type { BrowserViewBounds } from '@sophie/shared'; | |||
22 | import { BrowserView } from 'electron'; | 22 | import { BrowserView } from 'electron'; |
23 | 23 | ||
24 | import type Service from '../../../stores/Service'; | 24 | import type Service from '../../../stores/Service'; |
25 | import { getLogger } from '../../../utils/log'; | ||
25 | import type Resources from '../../resources/Resources'; | 26 | import type Resources from '../../resources/Resources'; |
26 | import type { ServiceView } from '../types'; | 27 | import type { ServiceView } from '../types'; |
27 | 28 | ||
28 | import ElectronPartition from './ElectronPartition'; | 29 | import ElectronPartition from './ElectronPartition'; |
29 | import type ElectronViewFactory from './ElectronViewFactory'; | 30 | import type ElectronViewFactory from './ElectronViewFactory'; |
30 | 31 | ||
32 | const log = getLogger('ElectronServiceView'); | ||
33 | |||
31 | export default class ElectronServiceView implements ServiceView { | 34 | export default class ElectronServiceView implements ServiceView { |
32 | readonly id: string; | 35 | readonly id: string; |
33 | 36 | ||
@@ -72,20 +75,39 @@ export default class ElectronServiceView implements ServiceView { | |||
72 | } | 75 | } |
73 | }); | 76 | }); |
74 | 77 | ||
78 | webContents.on( | ||
79 | 'did-fail-load', | ||
80 | (_event, errorCode, errorDesc, url, isMainFrame) => { | ||
81 | if (isMainFrame) { | ||
82 | setLocation(url); | ||
83 | service.setFailed(errorCode, errorDesc); | ||
84 | log.warn( | ||
85 | 'Failed to load', | ||
86 | url, | ||
87 | 'in service', | ||
88 | this.id, | ||
89 | errorCode, | ||
90 | errorDesc, | ||
91 | ); | ||
92 | } | ||
93 | }, | ||
94 | ); | ||
95 | |||
75 | webContents.on('page-title-updated', (_event, title) => { | 96 | webContents.on('page-title-updated', (_event, title) => { |
76 | service.setTitle(title); | 97 | service.setTitle(title); |
77 | }); | 98 | }); |
78 | 99 | ||
79 | webContents.on('did-start-loading', () => { | 100 | webContents.on('did-start-loading', () => { |
80 | service.startedLoading(); | 101 | service.startLoading(); |
81 | }); | 102 | }); |
82 | 103 | ||
83 | webContents.on('did-stop-loading', () => { | 104 | webContents.on('did-stop-loading', () => { |
84 | service.finishedLoading(); | 105 | service.finishLoading(); |
85 | }); | 106 | }); |
86 | 107 | ||
87 | webContents.on('render-process-gone', () => { | 108 | webContents.on('render-process-gone', (_event, details) => { |
88 | service.crashed(); | 109 | const { reason, exitCode } = details; |
110 | service.setCrashed(reason, exitCode); | ||
89 | }); | 111 | }); |
90 | } | 112 | } |
91 | 113 | ||
@@ -93,8 +115,10 @@ export default class ElectronServiceView implements ServiceView { | |||
93 | return this.browserView.webContents.id; | 115 | return this.browserView.webContents.id; |
94 | } | 116 | } |
95 | 117 | ||
96 | loadURL(url: string): Promise<void> { | 118 | loadURL(url: string): void { |
97 | return this.browserView.webContents.loadURL(url); | 119 | this.browserView.webContents.loadURL(url).catch((error) => { |
120 | log.warn('Error while loading', url, 'in service', this.id, error); | ||
121 | }); | ||
98 | } | 122 | } |
99 | 123 | ||
100 | goBack(): void { | 124 | goBack(): void { |
diff --git a/packages/main/src/infrastructure/electron/types.ts b/packages/main/src/infrastructure/electron/types.ts index 63974ce..7b04a6b 100644 --- a/packages/main/src/infrastructure/electron/types.ts +++ b/packages/main/src/infrastructure/electron/types.ts | |||
@@ -55,7 +55,7 @@ export interface ServiceView { | |||
55 | 55 | ||
56 | readonly partitionId: string; | 56 | readonly partitionId: string; |
57 | 57 | ||
58 | loadURL(url: string): Promise<void>; | 58 | loadURL(url: string): void; |
59 | 59 | ||
60 | goBack(): void; | 60 | goBack(): void; |
61 | 61 | ||