mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-03-23 09:51:10 +01:00
Remove updated_by, remember last location
This commit is contained in:
@@ -11,13 +11,12 @@ export async function setKeyValue<T>({
|
||||
namespace?: string;
|
||||
key: string | string[];
|
||||
value: T;
|
||||
}): Promise<T> {
|
||||
}): Promise<void> {
|
||||
await invoke('set_key_value', {
|
||||
namespace,
|
||||
key: buildKeyValueKey(key),
|
||||
value: JSON.stringify(value),
|
||||
});
|
||||
return value;
|
||||
}
|
||||
|
||||
export async function getKeyValue<T>({
|
||||
|
||||
17
src-web/lib/lastLocation.ts
Normal file
17
src-web/lib/lastLocation.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
import { getKeyValue, setKeyValue } from './keyValueStore';
|
||||
|
||||
export async function getLastLocation(): Promise<string> {
|
||||
return getKeyValue({ key: 'last_location', fallback: '/' });
|
||||
}
|
||||
|
||||
export async function setLastLocation(pathname: string): Promise<void> {
|
||||
return setKeyValue({ key: 'last_location', value: pathname });
|
||||
}
|
||||
|
||||
export async function syncLastLocation(): Promise<void> {
|
||||
const lastPathname = await getLastLocation();
|
||||
if (lastPathname !== window.location.pathname) {
|
||||
console.log(`Redirecting to last location: ${lastPathname}`);
|
||||
window.location.assign(lastPathname);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user