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 getSidebarWidth = useCallback((num: number) => {
if (num < 160) {
return 160;
if (num < 165) {
return 165;
}
if (num > 400) {
@ -64,7 +64,9 @@ const Sidebar = ({
const handleResizeEnd = useCallback(
(e: MouseEvent) => {
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);
document.body.style.cursor = 'default';
}

6
src/redux/configSlice.ts

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

Loading…
Cancel
Save