diff --git a/app/(auth)/(tabs)/(home)/index.tsx b/app/(auth)/(tabs)/(home)/index.tsx
index d4a56945..62d89b07 100644
--- a/app/(auth)/(tabs)/(home)/index.tsx
+++ b/app/(auth)/(tabs)/(home)/index.tsx
@@ -5,6 +5,7 @@ import { ScrollingCollectionList } from "@/components/home/ScrollingCollectionLi
import { Loader } from "@/components/Loader";
import { MediaListSection } from "@/components/medialists/MediaListSection";
import { TAB_HEIGHT } from "@/constants/Values";
+import { useDownload } from "@/providers/DownloadProvider";
import { apiAtom, userAtom } from "@/providers/JellyfinProvider";
import { useSettings } from "@/utils/atoms/settings";
import { Feather, Ionicons } from "@expo/vector-icons";
@@ -72,55 +73,26 @@ export default function index() {
setLoadingRetry(false);
}, []);
+ const { downloadedFiles } = useDownload();
+
useEffect(() => {
- try {
- // we check for downloaded files and turn the downloads button green if there are downloads
- AsyncStorage.getItem("downloaded_files").then((value) => {
- let downloadButtonColor = "white";
- if (value) {
- const files = JSON.parse(value) as BaseItemDto[];
- if (files.length > 0) {
- downloadButtonColor = "green";
- } else {
- downloadButtonColor = "white";
- }
- } else {
- downloadButtonColor = "white";
- }
- console.log("color: ", downloadButtonColor);
- navigation.setOptions({
- headerLeft: () => (
- {
- router.push("/(auth)/downloads");
- }}
- >
-
-
- ),
- });
- });
- } catch (error) {
- console.log(error);
- navigation.setOptions({
- headerLeft: () => (
- {
- router.push("/(auth)/downloads");
- }}
- >
-
-
- ),
- });
- }
- }, [navigation.getState()]);
+ const color =
+ downloadedFiles && downloadedFiles?.length > 0 ? "#9334E9" : "white";
+ navigation.setOptions({
+ headerLeft: () => (
+ {
+ router.push("/(auth)/downloads");
+ }}
+ >
+
+
+ ),
+ });
+ }, [downloadedFiles, navigation]);
useEffect(() => {
const unsubscribe = NetInfo.addEventListener((state) => {