minor tweak dimensionsChange and setNewTheme
This commit is contained in:
parent
80dc211911
commit
1c5561255f
|
@ -164,23 +164,18 @@ const Root = () => {
|
|||
}, []);
|
||||
|
||||
// Dimensions update fires twice
|
||||
const onDimensionsChange = useCallback(
|
||||
debounce(({ window }: { window: IDimensions }) => {
|
||||
setDimensions(window);
|
||||
setMasterDetail(window.width);
|
||||
}),
|
||||
[]
|
||||
);
|
||||
const onDimensionsChange = debounce(({ window }: { window: IDimensions }) => {
|
||||
setDimensions(window);
|
||||
setMasterDetail(window.width);
|
||||
});
|
||||
|
||||
const setNewTheme = (newThemePreference = {} as IThemePreference) => {
|
||||
const setNewTheme = (newThemePreference?: IThemePreference) => {
|
||||
const { theme: newTheme, themePreferences: newThemePreferences } = newThemeState(themePreferences, newThemePreference);
|
||||
setThemePreferences(newThemePreferences);
|
||||
setTheme(newTheme);
|
||||
subscribeTheme(themePreferences, setNewTheme);
|
||||
};
|
||||
|
||||
console.count('💸 Root');
|
||||
|
||||
return (
|
||||
<SafeAreaProvider initialMetrics={initialWindowMetrics} style={{ backgroundColor: themes[theme].backgroundColor }}>
|
||||
<Provider store={store}>
|
||||
|
|
|
@ -36,10 +36,10 @@ export const getTheme = (themePreferences: IThemePreference): TSupportedThemes =
|
|||
return theme === 'dark' ? darkLevel : 'light';
|
||||
};
|
||||
|
||||
export const newThemeState = (prevthemePreferences: IThemePreference, newTheme: IThemePreference) => {
|
||||
export const newThemeState = (prevThemePreferences: IThemePreference, newTheme?: IThemePreference) => {
|
||||
// new theme preferences
|
||||
const themePreferences = {
|
||||
...prevthemePreferences,
|
||||
...prevThemePreferences,
|
||||
...newTheme
|
||||
};
|
||||
// set new state of themePreferences
|
||||
|
|
Loading…
Reference in New Issue