diff --git a/app/(auth)/(tabs)/(home)/downloads.tsx b/app/(auth)/(tabs)/(home)/downloads.tsx index 20429bd4..d50aa586 100644 --- a/app/(auth)/(tabs)/(home)/downloads.tsx +++ b/app/(auth)/(tabs)/(home)/downloads.tsx @@ -39,59 +39,6 @@ const downloads: React.FC = () => { return Object.values(series); }, [downloadedFiles]); - useEffect(() => { - (async () => { - const dir = FileSystem.documentDirectory; - if (dir) { - const items = await FileSystem.readDirectoryAsync(dir); - - if (items.length === 0) { - console.log("No items found in the document directory."); - return; - } - - for (const item of items) { - const fullPath = `${dir}${item}`; - const info = await FileSystem.getInfoAsync(fullPath); - - if (info.exists) { - if (info.isDirectory) { - // List items in the directory - // const subItems = await FileSystem.readDirectoryAsync(fullPath); - // if (subItems.length === 0) { - // console.log(`Directory ${item} is empty.`); - // } else { - // console.log(`Items in ${item}:`, subItems); - // // If item ends in m3u8, print the content of the file - // const m3u8Files = subItems.filter((subItem) => - // subItem.endsWith(".m3u8") - // ); - // if (m3u8Files.length === 0) { - // console.log(`No .m3u8 files found in ${item}.`); - // } else { - // for (let subItem of m3u8Files) { - // console.log( - // `Content of ${subItem}:`, - // await FileSystem.readAsStringAsync( - // `${fullPath}/${subItem}` - // ) - // ); - // } - // } - // } - } else { - console.log(`${item} is a file`); - } - } else { - console.log(`${item} does not exist.`); - } - } - } else { - console.log("Document directory is not available."); - } - })(); - }, []); - const insets = useSafeAreaInsets(); return ( @@ -121,9 +68,9 @@ const downloads: React.FC = () => { { clearProcess(); - setQueue(async (prev) => { + setQueue((prev) => { if (!prev) return []; - return [...(await prev).filter((i) => i.id !== q.id)]; + return [...prev.filter((i) => i.id !== q.id)]; }); }} > diff --git a/app/(auth)/(tabs)/(home)/settings.tsx b/app/(auth)/(tabs)/(home)/settings.tsx index 834ba569..86fb08b5 100644 --- a/app/(auth)/(tabs)/(home)/settings.tsx +++ b/app/(auth)/(tabs)/(home)/settings.tsx @@ -39,7 +39,6 @@ export default function settings() { code: text, userId: user?.Id, }); - console.log(res.status, res.statusText, res.data); if (res.status === 200) { Haptics.notificationAsync( Haptics.NotificationFeedbackType.Success diff --git a/app/(auth)/(tabs)/(home,libraries,search)/series/[id].tsx b/app/(auth)/(tabs)/(home,libraries,search)/series/[id].tsx index 73870886..0ff4881b 100644 --- a/app/(auth)/(tabs)/(home,libraries,search)/series/[id].tsx +++ b/app/(auth)/(tabs)/(home,libraries,search)/series/[id].tsx @@ -20,8 +20,6 @@ const page: React.FC = () => { seasonIndex: string; }; - console.log("seasonIndex", seasonIndex); - const [api] = useAtom(apiAtom); const [user] = useAtom(userAtom); diff --git a/app/(auth)/(tabs)/(libraries)/[libraryId].tsx b/app/(auth)/(tabs)/(libraries)/[libraryId].tsx index ba217686..f2439409 100644 --- a/app/(auth)/(tabs)/(libraries)/[libraryId].tsx +++ b/app/(auth)/(tabs)/(libraries)/[libraryId].tsx @@ -69,13 +69,11 @@ const Page = () => { useEffect(() => { const sop = getSortOrderPreference(libraryId, sortOrderPreference); if (sop) { - console.log("getSortOrderPreference ~", sop, libraryId); _setSortOrder([sop]); } else { _setSortOrder([SortOrderOption.Ascending]); } const obp = getSortByPreference(libraryId, sortByPreference); - console.log("getSortByPreference ~", obp, libraryId); if (obp) { _setSortBy([obp]); } else { @@ -87,7 +85,6 @@ const Page = () => { (sortBy: SortByOption[]) => { const sop = getSortByPreference(libraryId, sortByPreference); if (sortBy[0] !== sop) { - console.log("setSortByPreference ~", sortBy[0], libraryId); setSortByPreference({ ...sortByPreference, [libraryId]: sortBy[0] }); } _setSortBy(sortBy); @@ -99,7 +96,6 @@ const Page = () => { (sortOrder: SortOrderOption[]) => { const sop = getSortOrderPreference(libraryId, sortOrderPreference); if (sortOrder[0] !== sop) { - console.log("setSortOrderPreference ~", sortOrder[0], libraryId); setOderByPreference({ ...sortOrderPreference, [libraryId]: sortOrder[0], diff --git a/app/_layout.tsx b/app/_layout.tsx index b638b9c8..df850e65 100644 --- a/app/_layout.tsx +++ b/app/_layout.tsx @@ -99,7 +99,6 @@ function Layout() { useEffect(() => { const subscription = ScreenOrientation.addOrientationChangeListener( (event) => { - console.log(event.orientationInfo.orientation); setOrientation(event.orientationInfo.orientation); } ); diff --git a/components/DownloadItem.tsx b/components/DownloadItem.tsx index e34ccb94..99bfe8a6 100644 --- a/components/DownloadItem.tsx +++ b/components/DownloadItem.tsx @@ -29,6 +29,7 @@ import { Loader } from "./Loader"; import { MediaSourceSelector } from "./MediaSourceSelector"; import ProgressCircle from "./ProgressCircle"; import { SubtitleTrackSelector } from "./SubtitleTrackSelector"; +import { toast } from "sonner-native"; interface DownloadProps extends ViewProps { item: BaseItemDto; @@ -65,9 +66,7 @@ export const DownloadItem: React.FC = ({ item, ...props }) => { bottomSheetModalRef.current?.present(); }, []); - const handleSheetChanges = useCallback((index: number) => { - console.log("handleSheetChanges", index); - }, []); + const handleSheetChanges = useCallback((index: number) => {}, []); const closeModal = useCallback(() => { bottomSheetModalRef.current?.dismiss(); @@ -286,22 +285,19 @@ export const DownloadItem: React.FC = ({ item, ...props }) => { onPress={() => { if (userCanDownload === true) { if (!item.Id) { - Alert.alert("Error", "Item ID is undefined."); - return; + throw new Error("No item id"); } closeModal(); - queueActions.enqueue(queue, setQueue, { - id: item.Id, - execute: async () => { - await initiateDownload(); - }, - item, - }); + initiateDownload(); + // Remove for now + // queueActions.enqueue(queue, setQueue, { + // id: item.Id, + // execute: async () => { + // }, + // item, + // }); } else { - Alert.alert( - "Disabled", - "This user is not allowed to download files." - ); + toast.error("You are not allowed to download files."); } }} color="purple" diff --git a/components/ItemContent.tsx b/components/ItemContent.tsx index 3afdca8b..4daee193 100644 --- a/components/ItemContent.tsx +++ b/components/ItemContent.tsx @@ -118,8 +118,6 @@ export const ItemContent: React.FC<{ id: string }> = React.memo(({ id }) => { itemId: id, }); - console.log("itemID", res?.Id); - return res; }, enabled: !!id && !!api, diff --git a/components/PlayButton.tsx b/components/PlayButton.tsx index d36554f3..a50249c5 100644 --- a/components/PlayButton.tsx +++ b/components/PlayButton.tsx @@ -163,7 +163,6 @@ export const PlayButton: React.FC = ({ item, url, ...props }) => { }); break; case 1: - console.log("Device"); setCurrentlyPlayingState({ item, url }); router.push("/play"); break; diff --git a/components/downloads/ActiveDownload.tsx b/components/downloads/ActiveDownload.tsx index c386ecea..8ce525cc 100644 --- a/components/downloads/ActiveDownload.tsx +++ b/components/downloads/ActiveDownload.tsx @@ -76,7 +76,6 @@ export const ActiveDownload: React.FC = ({ ...props }) => { {process.item.Name} - {process.item.Id} {process.item.Type} {process.progress.toFixed(0)}% diff --git a/providers/DownloadProvider.tsx b/providers/DownloadProvider.tsx index c71e9781..2fdc38a2 100644 --- a/providers/DownloadProvider.tsx +++ b/providers/DownloadProvider.tsx @@ -14,6 +14,7 @@ import { } from "@tanstack/react-query"; import axios from "axios"; import * as FileSystem from "expo-file-system"; +import { useRouter } from "expo-router"; import React, { createContext, useCallback, @@ -42,7 +43,7 @@ function useDownloadProvider() { const queryClient = useQueryClient(); const [process, setProcess] = useState(null); const [settings] = useSettings(); - + const router = useRouter(); const authHeader = useMemo(() => { return `Bearer ${settings?.optimizedVersionsAuthHeader}`; }, [settings]); @@ -185,8 +186,6 @@ function useDownloadProvider() { return; } - // console.log("Job ~", job); - // Update the local process state with the state from the server. let newState: ProcessItem["state"] = "optimizing"; if (job.status === "completed") { @@ -260,7 +259,14 @@ function useDownloadProvider() { state: "optimizing", }); - toast.success(`Optimization started for ${item.Name}`); + toast.success(`Optimization started for ${item.Name}`, { + action: { + label: "Go to download", + onClick: () => { + router.push("/downloads"); + }, + }, + }); } catch (error) { console.error("Error in startBackgroundDownload:", error); toast.error(`Failed to start download for ${item.Name}`); diff --git a/utils/atoms/queue.ts b/utils/atoms/queue.ts index de6a7336..2950d55a 100644 --- a/utils/atoms/queue.ts +++ b/utils/atoms/queue.ts @@ -10,31 +10,9 @@ export interface Job { execute: () => void | Promise; } -export const runningAtom = atomWithStorage("queueRunning", false, { - getItem: async (key) => { - const value = await AsyncStorage.getItem(key); - return value ? JSON.parse(value) : false; - }, - setItem: async (key, value) => { - await AsyncStorage.setItem(key, JSON.stringify(value)); - }, - removeItem: async (key) => { - await AsyncStorage.removeItem(key); - }, -}); +export const runningAtom = atom(false); -export const queueAtom = atomWithStorage("queueJobs", [], { - getItem: async (key) => { - const value = await AsyncStorage.getItem(key); - return value ? JSON.parse(value) : []; - }, - setItem: async (key, value) => { - await AsyncStorage.setItem(key, JSON.stringify(value)); - }, - removeItem: async (key) => { - await AsyncStorage.removeItem(key); - }, -}); +export const queueAtom = atom([]); export const queueActions = { enqueue: (queue: Job[], setQueue: (update: Job[]) => void, job: Job) => {