Refactor to use Redux
Signed-off-by: Nikolaos Karaolidis <nick@karaolidis.com>
This commit is contained in:
@@ -3,20 +3,22 @@ import { View } from 'react-native';
|
||||
import { Button, List, Snackbar, Switch, Text } from 'react-native-paper';
|
||||
import { useRealm } from '@realm/react';
|
||||
import { openDocumentTree } from 'react-native-scoped-storage';
|
||||
import { useDispatch, useSelector } from 'react-redux';
|
||||
import { PaddedView } from '../components';
|
||||
import styles from '../styles';
|
||||
import { Meme } from '../database';
|
||||
import { useStorageUri, useNoMedia } from '../contexts';
|
||||
import { RootState, updateNoMedia, updateStorageUri } from '../redux';
|
||||
import type {} from 'redux-thunk/extend-redux';
|
||||
|
||||
const SettingsScreen = () => {
|
||||
const [optimizingDatabase, setOptimizingDatabase] = useState(false);
|
||||
|
||||
const noMedia = useSelector((state: RootState) => state.settings.noMedia);
|
||||
const dispatch = useDispatch();
|
||||
|
||||
const [snackbarVisible, setSnackbarVisible] = useState(false);
|
||||
const [snackbarMessage, setSnackbarMessage] = useState('');
|
||||
|
||||
const [, setStorageUri] = useStorageUri();
|
||||
const [noMedia, setNoMedia] = useNoMedia();
|
||||
|
||||
const realm = useRealm();
|
||||
|
||||
const optimizeDatabase = () => {
|
||||
@@ -62,7 +64,7 @@ const SettingsScreen = () => {
|
||||
style={styles.marginBottom}
|
||||
onPress={async () => {
|
||||
const { uri } = await openDocumentTree(true);
|
||||
void setStorageUri(uri);
|
||||
void dispatch(updateStorageUri(uri));
|
||||
}}>
|
||||
Change External Storage Path
|
||||
</Button>
|
||||
@@ -76,7 +78,7 @@ const SettingsScreen = () => {
|
||||
<Switch
|
||||
value={noMedia}
|
||||
onValueChange={value => {
|
||||
void setNoMedia(value);
|
||||
void dispatch(updateNoMedia(value));
|
||||
}}
|
||||
/>
|
||||
</View>
|
||||
|
Reference in New Issue
Block a user