mirror of
https://github.com/cinnyapp/cinny.git
synced 2025-11-10 01:00:28 +03:00
add navToActivePath to clear cache function
This commit is contained in:
parent
0a4a7dabff
commit
269e8a1b49
2 changed files with 9 additions and 1 deletions
|
|
@ -9,6 +9,8 @@ import {
|
||||||
|
|
||||||
const NAV_TO_ACTIVE_PATH = 'navToActivePath';
|
const NAV_TO_ACTIVE_PATH = 'navToActivePath';
|
||||||
|
|
||||||
|
const getStoreKey = (userId: string): string => `${NAV_TO_ACTIVE_PATH}${userId}`;
|
||||||
|
|
||||||
type NavToActivePath = Map<string, Path>;
|
type NavToActivePath = Map<string, Path>;
|
||||||
|
|
||||||
type NavToActivePathAction =
|
type NavToActivePathAction =
|
||||||
|
|
@ -25,7 +27,7 @@ type NavToActivePathAction =
|
||||||
export type NavToActivePathAtom = WritableAtom<NavToActivePath, [NavToActivePathAction], undefined>;
|
export type NavToActivePathAtom = WritableAtom<NavToActivePath, [NavToActivePathAction], undefined>;
|
||||||
|
|
||||||
export const makeNavToActivePathAtom = (userId: string): NavToActivePathAtom => {
|
export const makeNavToActivePathAtom = (userId: string): NavToActivePathAtom => {
|
||||||
const storeKey = `${NAV_TO_ACTIVE_PATH}${userId}`;
|
const storeKey = getStoreKey(userId);
|
||||||
|
|
||||||
const baseNavToActivePathAtom = atomWithLocalStorage<NavToActivePath>(
|
const baseNavToActivePathAtom = atomWithLocalStorage<NavToActivePath>(
|
||||||
storeKey,
|
storeKey,
|
||||||
|
|
@ -64,3 +66,7 @@ export const makeNavToActivePathAtom = (userId: string): NavToActivePathAtom =>
|
||||||
|
|
||||||
return navToActivePathAtom;
|
return navToActivePathAtom;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const clearNavToActivePathStore = (userId: string) => {
|
||||||
|
localStorage.removeItem(getStoreKey(userId));
|
||||||
|
};
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
import { createClient, MatrixClient, IndexedDBStore, IndexedDBCryptoStore } from 'matrix-js-sdk';
|
import { createClient, MatrixClient, IndexedDBStore, IndexedDBCryptoStore } from 'matrix-js-sdk';
|
||||||
|
|
||||||
import { cryptoCallbacks } from './state/secretStorageKeys';
|
import { cryptoCallbacks } from './state/secretStorageKeys';
|
||||||
|
import { clearNavToActivePathStore } from '../app/state/navToActivePath';
|
||||||
|
|
||||||
type Session = {
|
type Session = {
|
||||||
baseUrl: string;
|
baseUrl: string;
|
||||||
|
|
@ -46,6 +47,7 @@ export const startClient = async (mx: MatrixClient) => {
|
||||||
|
|
||||||
export const clearCacheAndReload = async (mx: MatrixClient) => {
|
export const clearCacheAndReload = async (mx: MatrixClient) => {
|
||||||
mx.stopClient();
|
mx.stopClient();
|
||||||
|
clearNavToActivePathStore(mx.getSafeUserId());
|
||||||
await mx.store.deleteAllData();
|
await mx.store.deleteAllData();
|
||||||
window.location.reload();
|
window.location.reload();
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue