Cache settings
This commit is contained in:
parent
f27fbaa439
commit
d7d3cdc15b
@ -1,7 +1,7 @@
|
|||||||
import { createContext, useState } from "react";
|
import { createContext, useEffect, useState } from "react";
|
||||||
import { tableWidth } from "../data/constants";
|
import { tableWidth } from "../data/constants";
|
||||||
|
|
||||||
export const SettingsContext = createContext({
|
const defaultSettings = {
|
||||||
strictMode: false,
|
strictMode: false,
|
||||||
showFieldSummary: true,
|
showFieldSummary: true,
|
||||||
showGrid: true,
|
showGrid: true,
|
||||||
@ -11,20 +11,23 @@ export const SettingsContext = createContext({
|
|||||||
showCardinality: true,
|
showCardinality: true,
|
||||||
tableWidth: tableWidth,
|
tableWidth: tableWidth,
|
||||||
showDebugCoordinates: false,
|
showDebugCoordinates: false,
|
||||||
});
|
};
|
||||||
|
|
||||||
|
export const SettingsContext = createContext(defaultSettings);
|
||||||
|
|
||||||
export default function SettingsContextProvider({ children }) {
|
export default function SettingsContextProvider({ children }) {
|
||||||
const [settings, setSettings] = useState({
|
const [settings, setSettings] = useState(defaultSettings);
|
||||||
strictMode: false,
|
|
||||||
showFieldSummary: true,
|
useEffect(() => {
|
||||||
showGrid: true,
|
const settings = localStorage.getItem("settings");
|
||||||
mode: "light",
|
if (settings) {
|
||||||
autosave: true,
|
setSettings(JSON.parse(settings));
|
||||||
panning: true,
|
}
|
||||||
showCardinality: true,
|
}, []);
|
||||||
tableWidth: tableWidth,
|
|
||||||
showDebugCoordinates: false,
|
useEffect(() => {
|
||||||
});
|
localStorage.setItem("settings", JSON.stringify(settings));
|
||||||
|
}, [settings]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<SettingsContext.Provider value={{ settings, setSettings }}>
|
<SettingsContext.Provider value={{ settings, setSettings }}>
|
||||||
|
Loading…
Reference in New Issue
Block a user