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