From 74ddc58f8390ba23a418a2bc88d1ed016123f572 Mon Sep 17 00:00:00 2001 From: Lei Nelissen Date: Sun, 2 Jan 2022 18:11:30 +0100 Subject: [PATCH] Allow retries for failed tracks --- src/assets/arrow-clockwise.svg | 3 ++ src/screens/Downloads/index.tsx | 74 ++++++++++++++++++++++++--------- src/utility/JellyfinApi.ts | 1 - 3 files changed, 58 insertions(+), 20 deletions(-) create mode 100644 src/assets/arrow-clockwise.svg diff --git a/src/assets/arrow-clockwise.svg b/src/assets/arrow-clockwise.svg new file mode 100644 index 0000000..f403d59 --- /dev/null +++ b/src/assets/arrow-clockwise.svg @@ -0,0 +1,3 @@ + + + diff --git a/src/screens/Downloads/index.tsx b/src/screens/Downloads/index.tsx index 837601f..320c31c 100644 --- a/src/screens/Downloads/index.tsx +++ b/src/screens/Downloads/index.tsx @@ -1,17 +1,19 @@ import useDefaultStyles from 'components/Colors'; import React, { useCallback, useMemo } from 'react'; -import { Pressable, Text, View } from 'react-native'; +import { Text, TouchableOpacity, View } from 'react-native'; import { FlatList } from 'react-native-gesture-handler'; import { SafeAreaView } from 'react-native-safe-area-context'; import { useTypedSelector } from 'store'; import formatBytes from 'utility/formatBytes'; import TrashIcon from 'assets/trash.svg'; +import ArrowClockwise from 'assets/arrow-clockwise.svg'; import { THEME_COLOR } from 'CONSTANTS'; import { useDispatch } from 'react-redux'; import { EntityId } from '@reduxjs/toolkit'; -import { removeDownloadedTrack } from 'store/downloads/actions'; +import { downloadTrack, removeDownloadedTrack } from 'store/downloads/actions'; import Button from 'components/Button'; import { t } from 'i18n-js'; +import DownloadIcon from 'components/DownloadIcon'; function Downloads() { const defaultStyles = useDefaultStyles(); @@ -25,13 +27,18 @@ function Downloads() { ids?.reduce((sum, id) => sum + (entities[id]?.size || 0), 0) ), [ids, entities]); + // Describe handlers const handleDelete = useCallback((id: EntityId) => { dispatch(removeDownloadedTrack(id)); }, [dispatch]); const handleDeleteAllTracks = useCallback(() => { ids.forEach((id) => dispatch(removeDownloadedTrack(id))); }, [dispatch, ids]); + const retryTrack = useCallback((id: EntityId) => { + dispatch(downloadTrack(id)); + }, [dispatch]); + // If no tracks have beend ownloaded, show a short message describing this if (!ids.length) { return ( @@ -43,37 +50,66 @@ function Downloads() { } return ( - + {t('total-download-size')}: {formatBytes(totalDownloadSize)} } ListFooterComponent={ -