2020-08-28 14:17:37 +02:00
|
|
|
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';
|
2020-11-02 22:50:00 +01:00
|
|
|
import { t } from '@localisation';
|
2020-08-28 14:17:37 +02:00
|
|
|
|
|
|
|
|
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 (
|
|
|
|
|
<>
|
2020-11-02 22:50:00 +01:00
|
|
|
<SubHeader>{t('setting-cache')}</SubHeader>
|
|
|
|
|
<Text>{t('setting-cache-description')}</Text>
|
|
|
|
|
<Button title={t('reset-cache')} onPress={handleClearCache} color={THEME_COLOR} />
|
2020-08-28 14:17:37 +02:00
|
|
|
</>
|
|
|
|
|
);
|
|
|
|
|
}
|