Jon/keyed browser session id cache (#2928)
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
import React, { createContext, useMemo } from "react";
|
||||
import { useLocation } from "react-router-dom";
|
||||
import { lsKeys } from "@/util/env";
|
||||
|
||||
function useIsDebugMode() {
|
||||
const location = useLocation();
|
||||
@@ -10,23 +9,8 @@ function useIsDebugMode() {
|
||||
);
|
||||
}
|
||||
|
||||
function getCurrentBrowserSessionId() {
|
||||
const stored = localStorage.getItem(lsKeys.optimisticBrowserSession);
|
||||
let browserSessionId: string | null = null;
|
||||
try {
|
||||
const parsed = JSON.parse(stored ?? "");
|
||||
const { browser_session_id } = parsed;
|
||||
browserSessionId = browser_session_id as string;
|
||||
} catch {
|
||||
// pass
|
||||
}
|
||||
|
||||
return browserSessionId;
|
||||
}
|
||||
|
||||
export type DebugStoreContextType = {
|
||||
isDebugMode: boolean;
|
||||
getCurrentBrowserSessionId: () => string | null;
|
||||
};
|
||||
|
||||
export const DebugStoreContext = createContext<
|
||||
@@ -39,9 +23,7 @@ export const DebugStoreProvider: React.FC<{ children: React.ReactNode }> = ({
|
||||
const isDebugMode = useIsDebugMode();
|
||||
|
||||
return (
|
||||
<DebugStoreContext.Provider
|
||||
value={{ isDebugMode, getCurrentBrowserSessionId }}
|
||||
>
|
||||
<DebugStoreContext.Provider value={{ isDebugMode }}>
|
||||
{children}
|
||||
</DebugStoreContext.Provider>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user