Merge restore-fix: previous tabs reopen again
This commit is contained in:
commit
7bea16aa28
2 changed files with 16 additions and 9 deletions
21
main.js
21
main.js
|
|
@ -489,7 +489,7 @@ const SETTINGS_DEFAULTS = {
|
||||||
// means a session leaves no trace on disk unless the user opts in per-type.
|
// means a session leaves no trace on disk unless the user opts in per-type.
|
||||||
clearCookiesOnQuit: true, // drop cookies + logins + saved-form data
|
clearCookiesOnQuit: true, // drop cookies + logins + saved-form data
|
||||||
clearCacheOnQuit: true, // drop HTTP cache (images, scripts, etc.)
|
clearCacheOnQuit: true, // drop HTTP cache (images, scripts, etc.)
|
||||||
clearHistoryOnQuit: true, // drop navigation history + saved tabs
|
clearHistoryOnQuit: true, // drop navigation history (+ saved tabs unless restoreSession)
|
||||||
clearStorageOnQuit: true, // drop localStorage / IndexedDB / service workers / cache API
|
clearStorageOnQuit: true, // drop localStorage / IndexedDB / service workers / cache API
|
||||||
// Anti-fingerprinting — each: show (real) | hide (neutral) | spoof (auto decoy) | manual (user value)
|
// Anti-fingerprinting — each: show (real) | hide (neutral) | spoof (auto decoy) | manual (user value)
|
||||||
timezoneMode: "show", timezoneValue: "Europe/Berlin", // IANA zone for manual
|
timezoneMode: "show", timezoneValue: "Europe/Berlin", // IANA zone for manual
|
||||||
|
|
@ -1134,11 +1134,14 @@ async function clearBrowsingData({ cookies = false, cache = false, storage = fal
|
||||||
// navigation history lives in each webContents; drop it too when history-clear was asked.
|
// navigation history lives in each webContents; drop it too when history-clear was asked.
|
||||||
// (called separately by the before-quit hook, since history-clear also deletes session.json)
|
// (called separately by the before-quit hook, since history-clear also deletes session.json)
|
||||||
}
|
}
|
||||||
async function clearHistoryNow() {
|
// keepSession: leave session.json (the open tabs) in place. The quit clear
|
||||||
|
// passes it while "Open previous windows and tabs" is on — both default to on,
|
||||||
|
// and deleting the tab list made the restore setting a no-op for everyone.
|
||||||
|
async function clearHistoryNow({ keepSession = false } = {}) {
|
||||||
for (const t of tabs) {
|
for (const t of tabs) {
|
||||||
try { t.view.webContents.navigationHistory.clear(); } catch {}
|
try { t.view.webContents.navigationHistory.clear(); } catch {}
|
||||||
}
|
}
|
||||||
try { fs.unlinkSync(sessionFile()); } catch {}
|
if (!keepSession) { try { fs.unlinkSync(sessionFile()); } catch {} }
|
||||||
// Address-bar suggestions history — wipe both in-memory + on-disk.
|
// Address-bar suggestions history — wipe both in-memory + on-disk.
|
||||||
history = [];
|
history = [];
|
||||||
clearTimeout(historySaveTimer); historySaveTimer = null;
|
clearTimeout(historySaveTimer); historySaveTimer = null;
|
||||||
|
|
@ -8144,9 +8147,9 @@ if (!process.env.THESEUS_NO_AUTOSTART && !app.requestSingleInstanceLock()) {
|
||||||
if (quitClearing) return;
|
if (quitClearing) return;
|
||||||
quitClearing = true;
|
quitClearing = true;
|
||||||
flushAddonStores(); // add-on stores write coalesced; land them now
|
flushAddonStores(); // add-on stores write coalesced; land them now
|
||||||
// Auto-clear per user settings. saveSession() runs first so restoreSession
|
// Auto-clear per user settings. saveSession() runs first; clearing
|
||||||
// still works UNLESS the user asked to drop history — in which case we
|
// history keeps that tab list while restoreSession is on, and deletes it
|
||||||
// wipe the session file too so the next launch is genuinely blank.
|
// otherwise so the next launch is genuinely blank.
|
||||||
saveSession();
|
saveSession();
|
||||||
stopTor();
|
stopTor();
|
||||||
stopBnsPolling(); // silence the background delta refresh before exit
|
stopBnsPolling(); // silence the background delta refresh before exit
|
||||||
|
|
@ -8158,7 +8161,11 @@ if (!process.env.THESEUS_NO_AUTOSTART && !app.requestSingleInstanceLock()) {
|
||||||
storage: settings.clearStorageOnQuit,
|
storage: settings.clearStorageOnQuit,
|
||||||
});
|
});
|
||||||
// Session file AND the address-bar history (history.json).
|
// Session file AND the address-bar history (history.json).
|
||||||
if (settings.clearHistoryOnQuit) { await clearHistoryNow(); sessionDroppedForQuit = true; }
|
if (settings.clearHistoryOnQuit) {
|
||||||
|
const keepSession = !!settings.restoreSession;
|
||||||
|
await clearHistoryNow({ keepSession });
|
||||||
|
if (!keepSession) sessionDroppedForQuit = true;
|
||||||
|
}
|
||||||
})().catch((err) => console.error("before-quit clear failed:", err?.message));
|
})().catch((err) => console.error("before-quit clear failed:", err?.message));
|
||||||
Promise.race([clear, new Promise((r) => setTimeout(r, 5000))])
|
Promise.race([clear, new Promise((r) => setTimeout(r, 5000))])
|
||||||
.finally(() => { quitCleared = true; app.quit(); });
|
.finally(() => { quitCleared = true; app.quit(); });
|
||||||
|
|
|
||||||
|
|
@ -273,7 +273,7 @@
|
||||||
<p class="lede">Changes apply immediately and are saved for next time.</p>
|
<p class="lede">Changes apply immediately and are saved for next time.</p>
|
||||||
<h2 class="sub" style="border-top:0;padding-top:0;margin-top:0">Startup</h2>
|
<h2 class="sub" style="border-top:0;padding-top:0;margin-top:0">Startup</h2>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="txt"><div class="t">Open previous windows and tabs</div><div class="d">Restore the tabs from your last session when Theseus starts.</div></div>
|
<div class="txt"><div class="t">Open previous windows and tabs</div><div class="d">Restore the tabs from your last session when Theseus starts, even when history is cleared on quit.</div></div>
|
||||||
<label class="sw"><input type="checkbox" id="restoreSession"><span class="track"><span class="knob"></span></span></label>
|
<label class="sw"><input type="checkbox" id="restoreSession"><span class="track"><span class="knob"></span></span></label>
|
||||||
</div>
|
</div>
|
||||||
<div class="row" style="flex-direction:column;align-items:stretch;gap:8px">
|
<div class="row" style="flex-direction:column;align-items:stretch;gap:8px">
|
||||||
|
|
@ -812,7 +812,7 @@
|
||||||
<label class="sw"><input type="checkbox" id="clearStorageOnQuit"><span class="track"><span class="knob"></span></span></label>
|
<label class="sw"><input type="checkbox" id="clearStorageOnQuit"><span class="track"><span class="knob"></span></span></label>
|
||||||
</div>
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="txt"><div class="t">Clear history on quit</div><div class="d">Drops navigation history + the saved-tabs session file (overrides "Reopen previous tabs").</div></div>
|
<div class="txt"><div class="t">Clear history on quit</div><div class="d">Drops back/forward history and address-bar history. With "Open previous windows and tabs" on, the tabs themselves still reopen.</div></div>
|
||||||
<label class="sw"><input type="checkbox" id="clearHistoryOnQuit"><span class="track"><span class="knob"></span></span></label>
|
<label class="sw"><input type="checkbox" id="clearHistoryOnQuit"><span class="track"><span class="knob"></span></span></label>
|
||||||
</div>
|
</div>
|
||||||
<div class="row" style="justify-content:flex-end">
|
<div class="row" style="justify-content:flex-end">
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue