|
@@ -29,6 +29,7 @@ import { NavigationContainerRef } from '@react-navigation/core';
|
29
|
29
|
import {
|
30
|
30
|
defaultPreferences,
|
31
|
31
|
PreferenceKeys,
|
|
32
|
+ PreferencesType,
|
32
|
33
|
retrievePreferences,
|
33
|
34
|
} from './src/utils/asyncStorage';
|
34
|
35
|
import PreferencesProvider from './src/components/providers/PreferencesProvider';
|
|
@@ -46,6 +47,7 @@ LogBox.ignoreLogs([
|
46
|
47
|
|
47
|
48
|
type StateType = {
|
48
|
49
|
isLoading: boolean;
|
|
50
|
+ initialPreferences: PreferencesType;
|
49
|
51
|
};
|
50
|
52
|
|
51
|
53
|
export default class App extends React.Component<{}, StateType> {
|
|
@@ -61,6 +63,7 @@ export default class App extends React.Component<{}, StateType> {
|
61
|
63
|
super(props);
|
62
|
64
|
this.state = {
|
63
|
65
|
isLoading: true,
|
|
66
|
+ initialPreferences: defaultPreferences,
|
64
|
67
|
};
|
65
|
68
|
initLocales();
|
66
|
69
|
this.navigatorRef = React.createRef();
|
|
@@ -103,9 +106,11 @@ export default class App extends React.Component<{}, StateType> {
|
103
|
106
|
/**
|
104
|
107
|
* Async loading is done, finish processing startup data
|
105
|
108
|
*/
|
106
|
|
- onLoadFinished = () => {
|
|
109
|
+ onLoadFinished = (values: Array<PreferencesType | void>) => {
|
|
110
|
+ const [preferences] = values;
|
107
|
111
|
this.setState({
|
108
|
112
|
isLoading: false,
|
|
113
|
+ initialPreferences: { ...(preferences as PreferencesType) },
|
109
|
114
|
});
|
110
|
115
|
SplashScreen.hide();
|
111
|
116
|
};
|
|
@@ -133,7 +138,7 @@ export default class App extends React.Component<{}, StateType> {
|
133
|
138
|
return null;
|
134
|
139
|
}
|
135
|
140
|
return (
|
136
|
|
- <PreferencesProvider initialPreferences={defaultPreferences}>
|
|
141
|
+ <PreferencesProvider initialPreferences={this.state.initialPreferences}>
|
137
|
142
|
<MainApp
|
138
|
143
|
ref={this.navigatorRef}
|
139
|
144
|
defaultHomeData={this.defaultHomeData}
|