Update setting hooks
Signed-off-by: Nikolaos Karaolidis <nick@karaolidis.com>
This commit is contained in:
@@ -6,7 +6,7 @@ import { openDocumentTree } from 'react-native-scoped-storage';
|
||||
import { PaddedView } from '../components';
|
||||
import styles from '../styles';
|
||||
import { Meme } from '../database';
|
||||
import { useSettings } from '../contexts';
|
||||
import { useStorageUri, useNoMedia } from '../contexts';
|
||||
|
||||
const SettingsScreen = () => {
|
||||
const [optimizingDatabase, setOptimizingDatabase] = useState(false);
|
||||
@@ -14,7 +14,8 @@ const SettingsScreen = () => {
|
||||
const [snackbarVisible, setSnackbarVisible] = useState(false);
|
||||
const [snackbarMessage, setSnackbarMessage] = useState('');
|
||||
|
||||
const { settings, setSettings } = useSettings();
|
||||
const [, setStorageUri] = useStorageUri();
|
||||
const [noMedia, setNoMedia] = useNoMedia();
|
||||
|
||||
const realm = useRealm();
|
||||
|
||||
@@ -59,10 +60,9 @@ const SettingsScreen = () => {
|
||||
<Button
|
||||
mode="elevated"
|
||||
style={styles.marginBottom}
|
||||
onPress={() => {
|
||||
void openDocumentTree(true).then(uri => {
|
||||
setSettings({ storageUri: uri.uri });
|
||||
});
|
||||
onPress={async () => {
|
||||
const { uri } = await openDocumentTree(true);
|
||||
void setStorageUri(uri);
|
||||
}}>
|
||||
Change External Storage Path
|
||||
</Button>
|
||||
@@ -74,9 +74,9 @@ const SettingsScreen = () => {
|
||||
]}>
|
||||
<Text>Hide media from gallery</Text>
|
||||
<Switch
|
||||
value={settings.noMedia}
|
||||
value={noMedia}
|
||||
onValueChange={value => {
|
||||
setSettings({ noMedia: value });
|
||||
void setNoMedia(value);
|
||||
}}
|
||||
/>
|
||||
</View>
|
||||
|
Reference in New Issue
Block a user