diff --git a/app/(auth)/(tabs)/(home)/_layout.tsx b/app/(auth)/(tabs)/(home)/_layout.tsx index 8e313eaf..fc135fda 100644 --- a/app/(auth)/(tabs)/(home)/_layout.tsx +++ b/app/(auth)/(tabs)/(home)/_layout.tsx @@ -61,6 +61,18 @@ export default function IndexLayout() { title: "", }} /> + + {Object.entries(nestedTabPageScreenOptions).map(([name, options]) => ( ))} diff --git a/app/(auth)/(tabs)/(home)/settings/popular-lists/page.tsx b/app/(auth)/(tabs)/(home)/settings/popular-lists/page.tsx new file mode 100644 index 00000000..5e7b1c79 --- /dev/null +++ b/app/(auth)/(tabs)/(home)/settings/popular-lists/page.tsx @@ -0,0 +1,106 @@ +import { Text } from "@/components/common/Text"; +import { ListGroup } from "@/components/list/ListGroup"; +import { ListItem } from "@/components/list/ListItem"; +import { Loader } from "@/components/Loader"; +import { apiAtom, userAtom } from "@/providers/JellyfinProvider"; +import { useSettings } from "@/utils/atoms/settings"; +import { getItemsApi } from "@jellyfin/sdk/lib/utils/api"; +import { useQuery, useQueryClient } from "@tanstack/react-query"; +import { useNavigation } from "expo-router"; +import { useAtom } from "jotai"; +import { Linking, Switch, View } from "react-native"; + +export default function page() { + const navigation = useNavigation(); + + const [api] = useAtom(apiAtom); + const [user] = useAtom(userAtom); + + const [settings, updateSettings] = useSettings(); + + const handleOpenLink = () => { + Linking.openURL("https://github.com/fredrikburmester/marlin-search"); + }; + + const queryClient = useQueryClient(); + + const { + data: mediaListCollections, + isLoading: isLoadingMediaListCollections, + } = useQuery({ + queryKey: ["sf_promoted", user?.Id, settings?.usePopularPlugin], + queryFn: async () => { + if (!api || !user?.Id) return []; + + const response = await getItemsApi(api).getItems({ + userId: user.Id, + tags: ["sf_promoted"], + recursive: true, + fields: ["Tags"], + includeItemTypes: ["BoxSet"], + }); + + return response.data.Items ?? []; + }, + enabled: !!api && !!user?.Id && settings?.usePopularPlugin === true, + staleTime: 0, + }); + + if (!settings) return null; + + return ( + + + { + updateSettings({ usePopularPlugin: true }); + queryClient.invalidateQueries({ queryKey: ["search"] }); + }} + > + { + updateSettings({ usePopularPlugin: value }); + }} + /> + + + + {settings.usePopularPlugin && ( + + {mediaListCollections?.map((mlc) => ( + + { + if (!settings.mediaListCollectionIds) { + updateSettings({ + mediaListCollectionIds: [mlc.Id!], + }); + return; + } + + updateSettings({ + mediaListCollectionIds: + settings.mediaListCollectionIds.includes(mlc.Id!) + ? settings.mediaListCollectionIds.filter( + (id) => id !== mlc.Id + ) + : [...settings.mediaListCollectionIds, mlc.Id!], + }); + }} + /> + + ))} + {isLoadingMediaListCollections && } + {mediaListCollections?.length === 0 && ( + + No collections found. Add some in Jellyfin. + + )} + + )} + + ); +} diff --git a/components/medialists/MediaListSection.tsx b/components/medialists/MediaListSection.tsx index 8474b866..ff5e60a2 100644 --- a/components/medialists/MediaListSection.tsx +++ b/components/medialists/MediaListSection.tsx @@ -61,7 +61,7 @@ export const MediaListSection: React.FC = ({ return ( - + {collection.Name} { const [api] = useAtom(apiAtom); const [user] = useAtom(userAtom); - const [marlinUrl, setMarlinUrl] = useState(""); /******************** * Background task @@ -61,29 +60,6 @@ export const OtherSettings: React.FC = () => { /********************** *********************/ - const queryClient = useQueryClient(); - - const { - data: mediaListCollections, - isLoading: isLoadingMediaListCollections, - } = useQuery({ - queryKey: ["sf_promoted", user?.Id, settings?.usePopularPlugin], - queryFn: async () => { - if (!api || !user?.Id) return []; - - const response = await getItemsApi(api).getItems({ - userId: user.Id, - tags: ["sf_promoted"], - recursive: true, - fields: ["Tags"], - includeItemTypes: ["BoxSet"], - }); - - return response.data.Items ?? []; - }, - enabled: !!api && !!user?.Id && settings?.usePopularPlugin === true, - staleTime: 0, - }); if (!settings) return null; @@ -211,40 +187,7 @@ export const OtherSettings: React.FC = () => { /> - {settings.usePopularPlugin && ( - - {mediaListCollections?.map((mlc) => ( - - { - if (!settings.mediaListCollectionIds) { - updateSettings({ - mediaListCollectionIds: [mlc.Id!], - }); - return; - } - - updateSettings({ - mediaListCollectionIds: - settings.mediaListCollectionIds.includes(mlc.Id!) - ? settings.mediaListCollectionIds.filter( - (id) => id !== mlc.Id - ) - : [...settings.mediaListCollectionIds, mlc.Id!], - }); - }} - /> - - ))} - {isLoadingMediaListCollections && } - {mediaListCollections?.length === 0 && ( - - No collections found. Add some in Jellyfin. - - )} - - )} + diff --git a/components/settings/PluginSettings.tsx b/components/settings/PluginSettings.tsx index 3df0171b..0da0cd59 100644 --- a/components/settings/PluginSettings.tsx +++ b/components/settings/PluginSettings.tsx @@ -24,6 +24,11 @@ export const PluginSettings = () => { title="Marlin Search" showArrow /> + router.push("/settings/popular-lists/page")} + title="Popular Lists" + showArrow + /> );