This commit is contained in:
Fredrik Burmester
2024-08-04 14:01:48 +02:00
parent 7e9ccc38e6
commit c4ae33510d
5 changed files with 175 additions and 46 deletions

View File

@@ -85,6 +85,16 @@ export default function index() {
staleTime: 60,
});
if (isError)
return (
<View className="flex flex-col items-center justify-center h-full -mt-12">
<Text className="text-3xl font-bold mb-2">Oops!</Text>
<Text className="text-center opacity-70">
Something went wrong.{"\n"}Please log out and in again.
</Text>
</View>
);
if (isLoading)
return (
<View className="justify-center items-center h-full">
@@ -92,8 +102,6 @@ export default function index() {
</View>
);
if (isError) return <Text>Error loading items</Text>;
if (!data || data.length === 0) return <Text>No data...</Text>;
return (

View File

@@ -1,9 +1,9 @@
import { Button } from "@/components/Button";
import { Text } from "@/components/common/Text";
import { runningProcesses } from "@/components/DownloadItem";
import { ListItem } from "@/components/ListItem";
import ProgressCircle from "@/components/ProgressCircle";
import { apiAtom, useJellyfin, userAtom } from "@/providers/JellyfinProvider";
import { runningProcesses } from "@/utils/atoms/downloads";
import { readFromLog } from "@/utils/log";
import { Ionicons } from "@expo/vector-icons";
import { BaseItemDto } from "@jellyfin/sdk/lib/generated-client/models";
@@ -38,14 +38,11 @@ const deleteFile = async (id: string | null | undefined) => {
(err) => console.error(err)
);
AsyncStorage.setItem(
"downloaded_files",
JSON.stringify([
JSON.parse(
(await AsyncStorage.getItem("downloaded_files")) || "[]"
).filter((f: string) => f !== id),
])
const currentFiles = JSON.parse(
(await AsyncStorage.getItem("downloaded_files")) ?? "[]"
);
const updatedFiles = currentFiles.filter((f: string) => f !== id);
await AsyncStorage.setItem("downloaded_files", JSON.stringify(updatedFiles));
};
const listDownloadedFiles = async () => {
@@ -81,6 +78,11 @@ export default function settings() {
(await AsyncStorage.getItem("downloaded_files")) || "[]"
) as BaseItemDto[];
console.log(
"Files",
data.map((i) => i.Name)
);
setFiles(data);
})();
}, [key]);
@@ -160,8 +162,8 @@ export default function settings() {
<Button
className="mb-2"
color="red"
onPress={() => {
deleteAllFiles();
onPress={async () => {
await deleteAllFiles();
setKey((prevKey) => prevKey + 1);
}}
>