Browse Source

Fix sidebar config persistence

master
jeffvli 3 years ago
parent
commit
58d567622e
  1. 8
      src/components/layout/Sidebar.tsx
  2. 6
      src/redux/configSlice.ts

8
src/components/layout/Sidebar.tsx

@ -45,8 +45,8 @@ const Sidebar = ({
const [sidebarBodyRef, { height: sidebarBodyHeight }] = useMeasure<HTMLDivElement>(); const [sidebarBodyRef, { height: sidebarBodyHeight }] = useMeasure<HTMLDivElement>();
const getSidebarWidth = useCallback((num: number) => { const getSidebarWidth = useCallback((num: number) => {
if (num < 160) { if (num < 165) {
return 160; return 165;
} }
if (num > 400) { if (num > 400) {
@ -64,7 +64,9 @@ const Sidebar = ({
const handleResizeEnd = useCallback( const handleResizeEnd = useCallback(
(e: MouseEvent) => { (e: MouseEvent) => {
if (isResizing) { if (isResizing) {
dispatch(setSidebar({ width: `${getSidebarWidth(e?.clientX)}px` })); const finalWidth = `${getSidebarWidth(e?.clientX)}px`;
dispatch(setSidebar({ width: finalWidth }));
settings.setSync('sidebar.width', finalWidth);
setIsResizing(false); setIsResizing(false);
document.body.style.cursor = 'default'; document.body.style.cursor = 'default';
} }

6
src/redux/configSlice.ts

@ -170,9 +170,9 @@ const initialState: ConfigPage = {
alignment: String(parsedSettings.gridAlignment), alignment: String(parsedSettings.gridAlignment),
}, },
sidebar: { sidebar: {
expand: Boolean(parsedSettings.sidebar?.expand) || true, expand: Boolean(parsedSettings.sidebar?.expand),
width: String(parsedSettings.sidebar?.width) || '225px', width: String(parsedSettings.sidebar?.width),
coverArt: Boolean(parsedSettings.sidebar?.coverArt) || true, coverArt: Boolean(parsedSettings.sidebar?.coverArt),
selected: parsedSettings.sidebar?.selected || [ selected: parsedSettings.sidebar?.selected || [
'dashboard', 'dashboard',
'nowplaying', 'nowplaying',

Loading…
Cancel
Save