Skip to content

Commit 2c45008

Browse files
authored
Merge pull request #524 from lockdown-systems/514-guest-view-manager-call
Fix `GUEST_VIEW_MANAGER_CALL` error for good (I hope)
2 parents 99225cd + 6e1d888 commit 2c45008

File tree

2 files changed

+23
-17
lines changed

2 files changed

+23
-17
lines changed

src/renderer/src/view_models/BaseViewModel.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,8 @@ export class BaseViewModel {
287287
await new Promise(resolve => setTimeout(resolve, 200));
288288
if (Date.now() - startTime >= timeout) {
289289
this.log("waitForLoadingToFinish", "timeout reached while waiting for loading to finish");
290+
// Force stop any navigation before returning
291+
this.getWebview()?.stop();
290292
return;
291293
}
292294
} while (this.getWebview()?.isLoading());
@@ -446,8 +448,7 @@ export class BaseViewModel {
446448
this.log("loadBlank");
447449
const webview = this.getWebview();
448450
if (webview) {
449-
// Note: We need to wait for the page to finish loading before and after this to prevent
450-
// Error: Error invoking remote method 'ELECTRON_GUEST_VIEW_MANAGER_CALL'
451+
// Note: We need to wait for the page to finish loading before and after to prevent GUEST_VIEW_MANAGER_CALL
451452
// https://github.com/electron/electron/issues/24171#issuecomment-953053293
452453
await this.waitForLoadingToFinish();
453454
await webview.loadURL("about:blank")
@@ -458,6 +459,10 @@ export class BaseViewModel {
458459
async loadURL(url: string) {
459460
const webview = this.getWebview();
460461
if (webview) {
462+
// Note: We need to wait for the page to finish loading before and after to prevent GUEST_VIEW_MANAGER_CALL
463+
// https://github.com/electron/electron/issues/24171#issuecomment-953053293
464+
await this.waitForLoadingToFinish();
465+
461466
let tries = 0;
462467
// eslint-disable-next-line no-constant-condition
463468
while (true) {
@@ -492,6 +497,7 @@ export class BaseViewModel {
492497
} else {
493498
this.log("loadURL", "webview is null");
494499
}
500+
495501
await this.waitForLoadingToFinish();
496502
}
497503

src/renderer/src/view_models/XViewModel.ts

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2862,7 +2862,7 @@ Hang on while I scroll down to your earliest bookmarks.`;
28622862

28632863
case State.WizardStart:
28642864
this.showBrowser = false;
2865-
await this.loadURL("about:blank");
2865+
await this.loadBlank();
28662866

28672867
// Make the user start where they last were
28682868
jobsType = getJobsType(this.account.id) || "";
@@ -2893,29 +2893,29 @@ Hang on while I scroll down to your earliest bookmarks.`;
28932893
28942894
You can either import an X archive, or I can build it from scratch by scrolling through your profile.`;
28952895
this.state = State.WizardDatabaseDisplay;
2896-
await this.loadURL("about:blank");
2896+
await this.loadBlank();
28972897
break;
28982898

28992899
case State.WizardImportStart:
29002900
this.showBrowser = false;
29012901
this.instructions = `
29022902
**Before you can import your X archive, you need to download it from X. Here's how.**`;
2903-
await this.loadURL("about:blank");
2903+
await this.loadBlank();
29042904
this.state = State.WizardImportStartDisplay;
29052905
break;
29062906

29072907
case State.WizardImportDownload:
29082908
this.showBrowser = false;
29092909
this.instructions = `You have requested your X archive, so now we wait.`;
2910-
await this.loadURL("about:blank");
2910+
await this.loadBlank();
29112911
this.state = State.WizardImportDownloadDisplay;
29122912
break;
29132913

29142914
case State.WizardImporting:
29152915
this.showBrowser = false;
29162916
this.instructions = `
29172917
**I'll help you import your X archive into your local database.**`;
2918-
await this.loadURL("about:blank");
2918+
await this.loadBlank();
29192919
this.state = State.WizardImportingDisplay;
29202920
break;
29212921

@@ -2926,7 +2926,7 @@ I'll help you build a private local database of your X data to the \`Documents\`
29262926
You'll be able to access it even after you delete it from X.
29272927
29282928
**Which data do you want to save?**`;
2929-
await this.loadURL("about:blank");
2929+
await this.loadBlank();
29302930
this.state = State.WizardBuildOptionsDisplay;
29312931
break;
29322932

@@ -2938,15 +2938,15 @@ You'll be able to access it even after you delete it from X.
29382938
- And I can also save a more detailed backup of your direct messages than is available in the official X archive.
29392939
29402940
**Which data do you want to save?**`;
2941-
await this.loadURL("about:blank");
2941+
await this.loadBlank();
29422942
this.state = State.WizardArchiveOptionsDisplay;
29432943
break;
29442944

29452945
case State.WizardDeleteOptions:
29462946
this.showBrowser = false;
29472947
this.instructions = `
29482948
**Which data do you want to delete?**`;
2949-
await this.loadURL("about:blank");
2949+
await this.loadBlank();
29502950
this.state = State.WizardDeleteOptionsDisplay;
29512951
break;
29522952

@@ -2955,7 +2955,7 @@ You'll be able to access it even after you delete it from X.
29552955
this.instructions = `I'm almost ready to start helping you claw back your data from X!
29562956
29572957
**Here's what I'm planning on doing.**`;
2958-
await this.loadURL("about:blank");
2958+
await this.loadBlank();
29592959
this.state = State.WizardReviewDisplay;
29602960
break;
29612961

@@ -2966,13 +2966,13 @@ You'll be able to access it even after you delete it from X.
29662966
if (databaseStatsString != "") {
29672967
this.instructions += `\n\nI've saved: **${await this.getDatabaseStatsString()}**.`
29682968
}
2969-
await this.loadURL("about:blank");
2969+
await this.loadBlank();
29702970
this.state = State.WizardDeleteReviewDisplay;
29712971
break;
29722972

29732973
case State.WizardMigrateToBluesky:
29742974
this.showBrowser = false;
2975-
await this.loadURL("about:blank");
2975+
await this.loadBlank();
29762976
this.instructions = `
29772977
**Just because you're quitting X doesn't mean your posts need to disappear.**
29782978
@@ -2986,7 +2986,7 @@ After you build a local database of your tweets, I can help you migrate them int
29862986
All done!
29872987
29882988
**Here's what I did.**`;
2989-
await this.loadURL("about:blank");
2989+
await this.loadBlank();
29902990
this.state = State.FinishedRunningJobsDisplay;
29912991
break;
29922992

@@ -2995,7 +2995,7 @@ All done!
29952995
this.instructions = `**I'm almost ready to delete your data from X!**
29962996
29972997
You can save all your data for free, but you need a Premium plan to delete your data.`;
2998-
await this.loadURL("about:blank");
2998+
await this.loadBlank();
29992999
this.state = State.WizardCheckPremiumDisplay;
30003000
break;
30013001

@@ -3029,13 +3029,13 @@ You can save all your data for free, but you need a Premium plan to delete your
30293029
this.state = State.FinishedRunningJobs;
30303030

30313031
this.showBrowser = false;
3032-
await this.loadURL("about:blank");
3032+
await this.loadBlank();
30333033
break;
30343034

30353035
case State.Debug:
30363036
// Stay in this state until the user cancels it
30373037
this.showBrowser = false
3038-
await this.loadURL("about:blank");
3038+
await this.loadBlank();
30393039
this.instructions = `I'm in my debug state.`;
30403040
while (this.state === State.Debug) {
30413041
await this.sleep(1000);

0 commit comments

Comments
 (0)