diff --git a/phone/src/apps/settings/components/SettingItem.tsx b/phone/src/apps/settings/components/SettingItem.tsx index 8dd485c..6665acf 100644 --- a/phone/src/apps/settings/components/SettingItem.tsx +++ b/phone/src/apps/settings/components/SettingItem.tsx @@ -6,6 +6,7 @@ import { ListItemIcon, } from '@material-ui/core'; import { SvgIconProps } from '@material-ui/core'; + interface IProps { options?: any; label: string; diff --git a/phone/src/apps/settings/components/SettingsApp.tsx b/phone/src/apps/settings/components/SettingsApp.tsx index 5d589e7..fc307e1 100644 --- a/phone/src/apps/settings/components/SettingsApp.tsx +++ b/phone/src/apps/settings/components/SettingsApp.tsx @@ -35,15 +35,9 @@ const SubHeaderComp = (props: { text: string }) => ( export const SettingsApp = () => { const settingsApp = useApp('SETTINGS'); const [config] = useConfig(); - const { setSettings, settings } = useSettings(); const [localVal, setVal, getStorageItem] = useLocalStorage(); const simcard = useSimcard(); - useEffect(() => { - console.log('new localstorage'); - // this will be used to trigger a alert that gives feedback when the a setting is changed - }, [localVal]); - const wallpapers = config.wallpapers.map( MapStringOptions(getStorageItem('wallpaper'), (val: string) => setVal('wallpaper', val) @@ -77,6 +71,10 @@ export const SettingsApp = () => { // TODO: These new settings all work + useEffect(() => { + // this will be used to trigger a alert that gives feedback when the a setting is changed + }, [setVal]); + const [openMenu, closeMenu, ContextMenu, isMenuOpen] = useContextMenu(); return ( diff --git a/phone/src/os/phone/hooks/forceUpdate.ts b/phone/src/os/phone/hooks/forceUpdate.ts new file mode 100644 index 0000000..ebf5e3c --- /dev/null +++ b/phone/src/os/phone/hooks/forceUpdate.ts @@ -0,0 +1,7 @@ +import { useRecoilState } from 'recoil'; +import { phoneState } from './state'; + +export const useForceUpdate = () => { + const [update, setUpdate] = useRecoilState(phoneState.forceUpdateState); + return { update, setUpdate }; +}; diff --git a/phone/src/os/phone/hooks/state.ts b/phone/src/os/phone/hooks/state.ts index 5c37fb6..1dc0ad3 100644 --- a/phone/src/os/phone/hooks/state.ts +++ b/phone/src/os/phone/hooks/state.ts @@ -9,4 +9,8 @@ export const phoneState = { key: 'phoneConfig', default: undefined, }), + forceUpdateState: atom({ + key: 'fuckingupdate', + default: 0, + }), }; diff --git a/phone/src/os/phone/hooks/useLocalStorage.ts b/phone/src/os/phone/hooks/useLocalStorage.ts index 9c8bd80..fab9019 100644 --- a/phone/src/os/phone/hooks/useLocalStorage.ts +++ b/phone/src/os/phone/hooks/useLocalStorage.ts @@ -1,4 +1,5 @@ import { useState } from 'react'; +import { useForceUpdate } from '../../../os/phone/hooks/forceUpdate'; // TODO: Integrate debug log to fetch when that branch is merged @@ -10,6 +11,7 @@ import { useState } from 'react'; */ function useLocalStorage(key?: string, initialValue?: T) { + const { update, setUpdate } = useForceUpdate(); // Serves as a nice identifying prefix for the key const UNIQ_PREFIX = 'npwd_phone_'; const [localVal, setLocalVal] = useState(() => { @@ -42,6 +44,7 @@ function useLocalStorage(key?: string, initialValue?: T) { const setVal = (localKey, value: T | ((val: T) => T)) => { console.log(localKey, value); try { + setUpdate(update + 1); // Same API as useState meaning we can accept a function for value const valForStore = value instanceof Function ? value(localVal) : value; // Save that state so we repli useState