@@ -7,7 +7,8 @@ import { ErrorBoundary } from 'react-error-boundary'
77import { trackException } from '../utils/Analytics'
88import { AiFillBug } from 'react-icons/ai'
99import { WiRefresh } from 'react-icons/wi'
10- import { APP } from '../Constants'
10+ import { APP , LS_PREFERENCES_KEY } from '../Constants'
11+ import AppStorage from '../services/localStorage'
1112
1213function ErrorFallback ( { error, resetErrorBoundary } ) {
1314 return (
@@ -24,7 +25,6 @@ function ErrorFallback({ error, resetErrorBoundary }) {
2425
2526export default function AppWrapper ( { children } ) {
2627 const configuration = useContext ( ConfigurationContext )
27-
2828 const [ state , dispatcher ] = useReducer (
2929 AppReducer ,
3030 {
@@ -42,22 +42,21 @@ export default function AppWrapper({ children }) {
4242 ] ,
4343 } ,
4444 ( initialState ) => {
45- try {
46- let preferences = AppStorage . getItem ( LS_PREFERENCES_KEY )
47- if ( preferences ) {
48- preferences = JSON . parse ( preferences )
49- preferences = {
50- ...preferences ,
51- userSelectedTags : supportedTags . filter ( ( tag ) =>
52- preferences . userSelectedTags . includes ( tag . value )
53- ) ,
54- }
55- return {
56- ...initialState ,
57- ...preferences ,
58- }
45+ let preferences = AppStorage . getItem ( LS_PREFERENCES_KEY )
46+ if ( preferences ) {
47+ preferences = JSON . parse ( preferences )
48+ preferences = {
49+ ...preferences ,
50+ userSelectedTags : configuration . supportedTags . filter ( ( tag ) =>
51+ preferences . userSelectedTags . includes ( tag . value )
52+ ) ,
53+ }
54+ return {
55+ ...initialState ,
56+ ...preferences ,
5957 }
60- } catch ( e ) { }
58+ }
59+
6160 return initialState
6261 }
6362 )
@@ -67,13 +66,8 @@ export default function AppWrapper({ children }) {
6766 }
6867
6968 return (
70- < ErrorBoundary
71- FallbackComponent = { ErrorFallback }
72- onError = { errorHandler }
73- onReset = { ( ) => {
74- // reset the state of your app so the error doesn't happen again
75- } } >
76- < PreferencesProvider value = { { ...state , state, dispatcher : dispatcher } } >
69+ < ErrorBoundary FallbackComponent = { ErrorFallback } onError = { errorHandler } >
70+ < PreferencesProvider value = { { ...state , dispatcher : dispatcher } } >
7771 { children }
7872 </ PreferencesProvider >
7973 </ ErrorBoundary >
0 commit comments