Refactor state
Signed-off-by: Nikolaos Karaolidis <nick@karaolidis.com>
This commit is contained in:
@@ -44,6 +44,8 @@ const updateStorageUri = createAsyncThunk(
|
||||
const updateNoMedia = createAsyncThunk(
|
||||
'settings/updateNoMedia',
|
||||
async (newNoMedia: boolean, { dispatch, getState }) => {
|
||||
dispatch(setNoMedia(newNoMedia));
|
||||
|
||||
const state = getState() as RootState;
|
||||
const { storageUri } = state.settings;
|
||||
if (!storageUri) return;
|
||||
@@ -51,12 +53,12 @@ const updateNoMedia = createAsyncThunk(
|
||||
const noMediaExists = await FileSystem.exists(
|
||||
AndroidScoped.appendPath(storageUri, '.nomedia'),
|
||||
);
|
||||
|
||||
if (newNoMedia && !noMediaExists) {
|
||||
await createFile(storageUri, '.nomedia', 'text/x-unknown');
|
||||
} else if (!newNoMedia && noMediaExists) {
|
||||
await deleteFile(AndroidScoped.appendPath(storageUri, '.nomedia'));
|
||||
}
|
||||
dispatch(setNoMedia(newNoMedia));
|
||||
},
|
||||
);
|
||||
|
||||
|
Reference in New Issue
Block a user