Refactor and improve layout resizing

This commit is contained in:
Gregory Schier
2023-03-25 21:16:10 -07:00
parent 391a436ed3
commit ae4a43f406
14 changed files with 294 additions and 289 deletions

View File

@@ -12,7 +12,8 @@ import { keyValueQueryKey } from '../hooks/useKeyValue';
import { requestsQueryKey } from '../hooks/useRequests';
import { responsesQueryKey } from '../hooks/useResponses';
import { routePaths } from '../hooks/useRoutes';
import { SidebarDisplayKeys } from '../hooks/useSidebarDisplay';
import type { SidebarDisplay } from '../hooks/useSidebarDisplay';
import { sidebarDisplayDefaultValue, sidebarDisplayKey } from '../hooks/useSidebarDisplay';
import { workspacesQueryKey } from '../hooks/useWorkspaces';
import { DEFAULT_FONT_SIZE } from '../lib/constants';
import { extractKeyValue, getKeyValue, setKeyValue } from '../lib/keyValueStore';
@@ -139,8 +140,14 @@ await listen('refresh', () => {
});
await listen('toggle_sidebar', async () => {
const hidden = await getKeyValue<boolean>({ key: SidebarDisplayKeys.hidden, fallback: false });
await setKeyValue({ key: SidebarDisplayKeys.hidden, value: !hidden });
const display = await getKeyValue<SidebarDisplay>({
key: sidebarDisplayKey,
fallback: sidebarDisplayDefaultValue,
});
await setKeyValue({
key: sidebarDisplayKey,
value: { width: display.width, hidden: !display.hidden },
});
});
await listen('zoom', ({ payload: zoomDelta }: { payload: number }) => {