feat(settings): using local storage to save settings

Need to ensure that when a new setting is set, we re-render the phone.
This commit is contained in:
Christopher committed 2020-12-13 21:59:10 +01:00
1 parent 08e21f4129
commit 3e03993d5b
5 files changed
+65 -34

No files matched your search

+10 -7
View File
@@ -1,16 +1,19 @@
import Default from "../default.json";
import { useConfig } from "../../../config/hooks/useConfig";
import { atom } from "recoil";
import { createMuiTheme } from "@material-ui/core";
import Default from '../default.json';
import { useConfig } from '../../../config/hooks/useConfig';
import { atom } from 'recoil';
import { createMuiTheme } from '@material-ui/core';
import useLocalStorage from '../../../os/phone/hooks/useLocalStorage';
const settingsState = atom({
key: "settings",
key: 'settings',
default: Default,
});
export const useSettings = (): any => {
const [settings, setSettings] = useConfig(settingsState);
const [, , getStorageItem] = useLocalStorage('theme', 'taso-dark');
const [settings, setSettings] = useLocalStorage();
const [config] = useConfig();
const currentTheme = () => createMuiTheme(config.themes[settings.theme]);
const currentTheme = () =>
createMuiTheme(config.themes[getStorageItem('theme')]);
return { settings, setSettings, currentTheme };
};