From 12b53eca4a5278fa4576a61ac8168b09bf4ecc49 Mon Sep 17 00:00:00 2001 From: Lei Nelissen Date: Fri, 28 Aug 2020 14:17:37 +0200 Subject: [PATCH] Allow for clearing the Redux store from the settings page --- src/screens/Settings/components/Cache.tsx | 26 +++++++++++ src/screens/Settings/components/Library.tsx | 44 ++++++++++++++++++ src/screens/Settings/index.tsx | 49 +++------------------ src/store/music/index.ts | 4 +- 4 files changed, 79 insertions(+), 44 deletions(-) create mode 100644 src/screens/Settings/components/Cache.tsx create mode 100644 src/screens/Settings/components/Library.tsx diff --git a/src/screens/Settings/components/Cache.tsx b/src/screens/Settings/components/Cache.tsx new file mode 100644 index 0000000..910ae1d --- /dev/null +++ b/src/screens/Settings/components/Cache.tsx @@ -0,0 +1,26 @@ +import React, { useCallback } from 'react'; +import TrackPlayer from 'react-native-track-player'; +import { SubHeader } from 'components/Typography'; +import { Text, Button } from 'react-native'; +import { THEME_COLOR } from 'CONSTANTS'; +import { useDispatch } from 'react-redux'; +import music from 'store/music'; + +export default function CacheSettings() { + const dispatch = useDispatch(); + const handleClearCache = useCallback(() => { + // Dispatch an action to reset the music subreducer state + dispatch(music.actions.reset()); + + // Also clear the TrackPlayer queue + TrackPlayer.reset(); + }, [dispatch]); + + return ( + <> + Cache + If you have updated your Jellyfin library, but the app is holding on to cached assets, you can forcefully clear the cache using this button. This will force the app to fetch the library from scratch. +