aboutsummaryrefslogtreecommitdiffhomepage
path: root/frontend/src/utilities/storage.ts
blob: a7c256cab94ae47fd01e481af012ec5f0e8e5bb5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import { useCallback } from "react";
import { useSystemSettings } from "@/apis/hooks";

export const uiPageSizeKey = "settings-general-page_size";

export function useUpdateLocalStorage() {
  return useCallback((newVals: LooseObject) => {
    for (const key in newVals) {
      const value = newVals[key];
      localStorage.setItem(key, value);
    }
  }, []);
}

export function usePageSize() {
  const settings = useSystemSettings();

  return settings.data?.general.page_size ?? 50;
}