Skip to content

Commit

Permalink
fixed reload for remote feature and added option to the electron hand…
Browse files Browse the repository at this point in the history
…ler to add change url (#13891)

Signed-off-by: Jonah Iden <jonah.iden@typefox.io>
  • Loading branch information
jonah-iden committed Jul 9, 2024
1 parent 77c66e4 commit 10b156c
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion packages/core/src/electron-browser/preload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ const api: TheiaCoreAPI = {
ipcRenderer.send(CHANNEL_TOGGLE_FULL_SCREEN);
},

requestReload: () => ipcRenderer.send(CHANNEL_REQUEST_RELOAD),
requestReload: (newUrl?: string) => ipcRenderer.send(CHANNEL_REQUEST_RELOAD, newUrl),
restart: () => ipcRenderer.send(CHANNEL_RESTART),

applicationStateChanged: state => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ export class ElectronWindowService extends DefaultWindowService {
if (params.hash) {
newLocation.hash = '#' + params.hash;
}
location.assign(newLocation);
window.electronTheiaCore.requestReload(newLocation.toString());
} else {
window.electronTheiaCore.requestReload();
}
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/electron-common/electron-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export interface TheiaCoreAPI {
isFullScreen(): boolean; // TODO: this should really be async, since it blocks the renderer process
toggleFullScreen(): void;

requestReload(): void;
requestReload(newUrl?: string): void;
restart(): void;

applicationStateChanged(state: FrontendApplicationState): void;
Expand Down
10 changes: 7 additions & 3 deletions packages/core/src/electron-main/theia-electron-window.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,10 +147,14 @@ export class TheiaElectronWindow {
return this.handleStopRequest(() => this.doCloseWindow(), reason);
}

protected reload(): void {
protected reload(newUrl?: string): void {
this.handleStopRequest(async () => {
this.applicationState = 'init';
this._window.reload();
if (newUrl) {
this._window.loadURL(newUrl);
} else {
this._window.reload();
}
}, StopReason.Reload);
}

Expand Down Expand Up @@ -195,7 +199,7 @@ export class TheiaElectronWindow {
}

protected attachReloadListener(): void {
this.toDispose.push(TheiaRendererAPI.onRequestReload(this.window.webContents, () => this.reload()));
this.toDispose.push(TheiaRendererAPI.onRequestReload(this.window.webContents, (newUrl?: string) => this.reload(newUrl)));
}

dispose(): void {
Expand Down

0 comments on commit 10b156c

Please sign in to comment.