fix: popular lists plugin

This commit is contained in:
Fredrik Burmester
2025-01-02 17:24:43 +01:00
parent 730823c520
commit b8dbce6bf2
5 changed files with 125 additions and 59 deletions

View File

@@ -61,7 +61,7 @@ export const MediaListSection: React.FC<Props> = ({
return (
<View {...props}>
<Text className="px-4 text-2xl font-bold mb-2 text-neutral-100">
<Text className="px-4 text-lg font-bold mb-2 text-neutral-100">
{collection.Name}
</Text>
<InfiniteHorizontalScroll

View File

@@ -29,7 +29,6 @@ export const OtherSettings: React.FC = () => {
const [api] = useAtom(apiAtom);
const [user] = useAtom(userAtom);
const [marlinUrl, setMarlinUrl] = useState<string>("");
/********************
* 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 = () => {
/>
</ListItem>
{settings.usePopularPlugin && (
<ListGroup title="Media List Collections">
{mediaListCollections?.map((mlc) => (
<ListItem key={mlc.Id} title={mlc.Name}>
<Switch
value={settings.mediaListCollectionIds?.includes(mlc.Id!)}
onValueChange={(value) => {
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!],
});
}}
/>
</ListItem>
))}
{isLoadingMediaListCollections && <Loader />}
{mediaListCollections?.length === 0 && (
<Text className="text-xs opacity-50 p-4">
No collections found. Add some in Jellyfin.
</Text>
)}
</ListGroup>
)}
<ListItem
title="Show Custom Menu Links"
onPress={() =>

View File

@@ -24,6 +24,11 @@ export const PluginSettings = () => {
title="Marlin Search"
showArrow
/>
<ListItem
onPress={() => router.push("/settings/popular-lists/page")}
title="Popular Lists"
showArrow
/>
</ListGroup>
</View>
);