feat: isolate user preferences in localStorage from each other
import { useState } from 'react';
+import Auth from 'contexts/Auth';
import { Storage, Store } from 'utils/storage';
export const useStorage = (basePath: string, store: Store = window.localStorage): Storage => {
+ const auth = Auth.useStateContext();
+ const userNamespace = auth.user ? `u:${auth.user.username}` : '';
const [ storage ] = useState(
- new Storage({ basePath, store }),
+ new Storage({ basePath: `${userNamespace}/${basePath}`, store }),
);
return storage;
};
