aboutsummaryrefslogtreecommitdiffstats
path: root/packages/main/src/infrastructure/electron/impl/ElectronServiceView.ts
diff options
context:
space:
mode:
Diffstat (limited to 'packages/main/src/infrastructure/electron/impl/ElectronServiceView.ts')
-rw-r--r--packages/main/src/infrastructure/electron/impl/ElectronServiceView.ts36
1 files changed, 30 insertions, 6 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';
22import { BrowserView } from 'electron'; 22import { BrowserView } from 'electron';
23 23
24import type Service from '../../../stores/Service'; 24import type Service from '../../../stores/Service';
25import { getLogger } from '../../../utils/log';
25import type Resources from '../../resources/Resources'; 26import type Resources from '../../resources/Resources';
26import type { ServiceView } from '../types'; 27import type { ServiceView } from '../types';
27 28
28import ElectronPartition from './ElectronPartition'; 29import ElectronPartition from './ElectronPartition';
29import type ElectronViewFactory from './ElectronViewFactory'; 30import type ElectronViewFactory from './ElectronViewFactory';
30 31
32const log = getLogger('ElectronServiceView');
33
31export default class ElectronServiceView implements ServiceView { 34export 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 {