2022-12-13 21:26:17 +00:00
|
|
|
import { get, put } from './lib';
|
|
|
|
|
|
|
|
interface State {
|
|
|
|
lon: number;
|
|
|
|
lat: number;
|
|
|
|
rotation: number;
|
|
|
|
zoom: number;
|
|
|
|
provider: string;
|
|
|
|
}
|
|
|
|
|
|
|
|
export const getState = async <State>() => {
|
|
|
|
try {
|
2022-12-24 15:39:55 +00:00
|
|
|
const state = (await get('state', true)).doc;
|
2022-12-13 21:26:17 +00:00
|
|
|
console.log({ caller: 'getState', state });
|
|
|
|
return state;
|
|
|
|
} catch {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
export const setState = async (state: State) => {
|
2022-12-24 15:39:55 +00:00
|
|
|
await put('state', 'state', (doc) => state, {}, true);
|
2022-12-13 21:26:17 +00:00
|
|
|
console.log({ caller: 'setState', state });
|
|
|
|
return 'state';
|
|
|
|
};
|