Remove updated_by, remember last location

This commit is contained in:
Gregory Schier
2023-03-30 08:11:51 -07:00
parent 904d20b9b8
commit 7fcf709efe
13 changed files with 286 additions and 346 deletions

View File

@@ -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>({

View 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);
}
}