Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed reload for remote feature and added option to the electron window to add change url on reload #13891

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading