Add AppState subscription
Signed-off-by: Nikolaos Karaolidis <nick@karaolidis.com>
This commit is contained in:
@@ -5,7 +5,7 @@ import React, {
|
|||||||
useEffect,
|
useEffect,
|
||||||
ReactNode,
|
ReactNode,
|
||||||
} from 'react';
|
} from 'react';
|
||||||
import { Settings } from '../types';
|
import { AppState } from 'react-native';
|
||||||
import AsyncStorage from '@react-native-async-storage/async-storage';
|
import AsyncStorage from '@react-native-async-storage/async-storage';
|
||||||
import { AndroidScoped, FileSystem } from 'react-native-file-access';
|
import { AndroidScoped, FileSystem } from 'react-native-file-access';
|
||||||
import {
|
import {
|
||||||
@@ -106,7 +106,11 @@ function SettingsProvider({ children }: { children: ReactNode }) {
|
|||||||
setHasLoaded(true);
|
setHasLoaded(true);
|
||||||
};
|
};
|
||||||
|
|
||||||
void loadSettings();
|
const subscription = AppState.addEventListener('change', () => {
|
||||||
|
if (AppState.currentState === 'active') void loadSettings();
|
||||||
|
});
|
||||||
|
|
||||||
|
return () => subscription.remove();
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
Reference in New Issue
Block a user