feat(phone/settings): Add localStorage settings schema validation (#139)

Will reset to default settings if the schema is invalid.
This commit is contained in:
J Francisco Rader authored and GitHub committed 2021-03-05 11:18:36 -05:00
1 parent 60431d2de7
commit cb5a00e57e
10 files changed
+136 -43

No files matched your search

+1 -1
View File
@@ -4,7 +4,7 @@ import { getSoundSettings } from '../utils/getSoundSettings';
import { useSoundProvider } from './useSoundProvider';
export const useRingtoneSound = () => {
const [settings] = useSettings();
const { settings } = useSettings();
const sound = useSoundProvider();
+2 -2
View File
@@ -17,11 +17,11 @@ export const getSoundSettings = (
try {
return app
? {
sound: getPath[type](settings[`${app}_${type}`].value || settings[type].value),
sound: getPath[type](settings[`${app}_${type}`]?.value || settings[type]?.value),
volume: (settings[`${app}_${type}Vol`] || settings[`${type}Vol`]) / 100,
}
: {
sound: getPath[type](settings[type as string].value),
sound: getPath[type](settings[type as string]?.value),
volume: settings[`${type}Vol`] / 100,
};
} catch (e) {