17 lines
638 B
TypeScript
17 lines
638 B
TypeScript
import { getLocalStorageItem, setLocalStorageItem } from './utils/atomWithLocalStorage';
|
|
|
|
const LAST_ACTIVE_PATH_KEY = 'lastActivePath';
|
|
|
|
const getStoreKey = (userId: string): string => `${LAST_ACTIVE_PATH_KEY}${userId}`;
|
|
|
|
/**
|
|
* Last channel (room route) the user opened, remembered per account so the app
|
|
* reopens there on startup instead of the inbox.
|
|
*/
|
|
export const getLastActivePath = (userId: string): string | undefined =>
|
|
getLocalStorageItem<string | undefined>(getStoreKey(userId), undefined);
|
|
|
|
export const setLastActivePath = (userId: string, path: string): void => {
|
|
setLocalStorageItem(getStoreKey(userId), path);
|
|
};
|