mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-11-21 16:01:46 +01:00
Persist window paths
This commit is contained in:
1 parent
cca8d97d63
commit
30e7f7ccfe
5 files changed
+38
-8
No files matched your search
@@ -0,0 +1,21 @@
|
||||
import { appWindow } from '@tauri-apps/api/window';
|
||||
import { NAMESPACE_NO_SYNC, getKeyValue, setKeyValue } from './keyValueStore';
|
||||
|
||||
const key = ['window_pathname', appWindow.label];
|
||||
const namespace = NAMESPACE_NO_SYNC;
|
||||
const fallback = undefined;
|
||||
|
||||
export async function initPathnamePersistance() {
|
||||
if (window.location.pathname === '/') {
|
||||
const pathname = await getKeyValue<string | undefined>({ key, namespace, fallback });
|
||||
if (pathname != null) {
|
||||
window.location.replace(pathname);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
window.addEventListener('pushstate', async () => {
|
||||
const { pathname: value } = window.location;
|
||||
await setKeyValue<string | undefined>({ key, namespace, value });
|
||||
});
|
||||
}
|
||||
Reference in new issue
Block a user