Update useMetricLayout.ts

This commit is contained in:
Nate Kelley 2025-02-05 13:19:49 -07:00
parent 55e307b677
commit 2fc8c9a221
No known key found for this signature in database
GPG Key ID: FD90372AB8D98B4F
1 changed files with 8 additions and 6 deletions

View File

@ -28,25 +28,27 @@ export const useMetricLayout = ({
const defaultOpenLayout = isChart ? defaultChartOpenLayout : defaultSqlOpenLayout; const defaultOpenLayout = isChart ? defaultChartOpenLayout : defaultSqlOpenLayout;
const defaultOriginalLayout = isChart ? defaultChartLayout : defaultSqlLayout; const defaultOriginalLayout = isChart ? defaultChartLayout : defaultSqlLayout;
const secondaryLayoutDimensions = useMemo(() => { const secondaryLayoutDimensions: [string, string] = useMemo(() => {
const cookieKey = createAutoSaveId(autoSaveId); const cookieKey = createAutoSaveId(autoSaveId);
const cookieValue = Cookies.get(cookieKey); const cookieValue = Cookies.get(cookieKey);
if (cookieValue) { if (cookieValue) {
try { try {
const parsedValue = JSON.parse(cookieValue); const parsedValue = JSON.parse(cookieValue) as string[];
return parsedValue; if (!parsedValue?.some((item) => item === 'auto')) {
return parsedValue as [string, string];
}
} catch (error) { } catch (error) {
// //
} }
} }
return defaultOpenLayout; return defaultOpenLayout as [string, string];
}, []); }, []);
const defaultLayout = useMemo(() => { const defaultLayout: [string, string] = useMemo(() => {
if (isOpenSecondary) { if (isOpenSecondary) {
return secondaryLayoutDimensions; return secondaryLayoutDimensions;
} }
return defaultOriginalLayout; return defaultOriginalLayout as [string, string];
}, []); }, []);
const animateOpenSplitter = useMemoizedFn((side: 'metric' | 'both') => { const animateOpenSplitter = useMemoizedFn((side: 'metric' | 'both') => {