Skip to content

Commit cdf53ab

Browse files
committed
fix: clear navigation history on window load events
- Added functionality to clear the navigation history for main, auth, and popup windows upon finishing loading, ensuring a clean state for user navigation. - Removed redundant history manipulation effects from RootPageComponent, AuthPageComponent, and PopupPageComponent to streamline the code.
1 parent 3b04ef2 commit cdf53ab

4 files changed

Lines changed: 9 additions & 18 deletions

File tree

main.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,7 @@ export async function createMainWindow(title?: string): Promise<BrowserWindow> {
347347

348348
mainWindow.webContents.on('did-finish-load', () => {
349349
mainWindow?.webContents.send(mainWindow?.isMaximized() ? 'maximize' : 'unmaximize');
350+
mainWindow?.webContents.navigationHistory.clear();
350351
});
351352

352353
mainWindow.webContents.setWindowOpenHandler(({ url }) => {
@@ -412,6 +413,10 @@ export async function createAuthWindow(title?: string): Promise<BrowserWindow> {
412413
app.exit();
413414
});
414415

416+
authWindow.webContents.on('did-finish-load', () => {
417+
authWindow?.webContents.navigationHistory.clear();
418+
});
419+
415420
authWindow.webContents.setWindowOpenHandler(({ url }) => {
416421
shell.openExternal(url);
417422
return { action: 'deny' };
@@ -506,6 +511,10 @@ export async function createPopup(type: PopupType, id: string, initialData: unkn
506511
popups[id]?.webContents.send('unmaximize');
507512
});
508513

514+
popups[id].webContents.on('did-finish-load', () => {
515+
popups[id]?.webContents.navigationHistory.clear();
516+
});
517+
509518
popups[id].webContents.setWindowOpenHandler(({ url }) => {
510519
shell.openExternal(url);
511520
return { action: 'deny' };

src/app/auth/page.tsx

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -84,12 +84,6 @@ const AuthPageComponent: React.FC = React.memo(() => {
8484
autoLogin();
8585
}, []);
8686

87-
useEffect(() => {
88-
history.pushState = () => {};
89-
history.back = () => {};
90-
history.forward = () => {};
91-
}, []);
92-
9387
return (
9488
<>
9589
<Header />

src/app/page.tsx

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -926,12 +926,6 @@ const RootPageComponent: React.FC = React.memo(() => {
926926
return () => unsub();
927927
}, []);
928928

929-
useEffect(() => {
930-
history.pushState = () => {};
931-
history.back = () => {};
932-
history.forward = () => {};
933-
}, []);
934-
935929
return (
936930
<WebRTCProvider>
937931
<ActionScannerProvider>

src/app/popup/page.tsx

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -439,12 +439,6 @@ const PopupPageComponent: React.FC = React.memo(() => {
439439
setInitialData(ipc.initialData.get(id));
440440
}, [id]);
441441

442-
useEffect(() => {
443-
history.pushState = () => {};
444-
history.back = () => {};
445-
history.forward = () => {};
446-
}, []);
447-
448442
return (
449443
<>
450444
{!hideHeader && (

0 commit comments

Comments
 (0)