mirror of
https://github.com/streamyfin/streamyfin.git
synced 2026-01-16 16:18:09 +00:00
Compare commits
4 Commits
develop
...
feat/refre
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4696671bf5 | ||
|
|
69d744c86f | ||
|
|
ad1bd72123 | ||
|
|
b93c56f300 |
@@ -35,6 +35,7 @@ import { ItemTechnicalDetails } from "./ItemTechnicalDetails";
|
|||||||
import { MediaSourceSheet } from "./MediaSourceSheet";
|
import { MediaSourceSheet } from "./MediaSourceSheet";
|
||||||
import { MoreMoviesWithActor } from "./MoreMoviesWithActor";
|
import { MoreMoviesWithActor } from "./MoreMoviesWithActor";
|
||||||
import { PlayInRemoteSessionButton } from "./PlayInRemoteSession";
|
import { PlayInRemoteSessionButton } from "./PlayInRemoteSession";
|
||||||
|
import { RefreshMetadata } from "./RefreshMetadata";
|
||||||
import { TrackSheet } from "./TrackSheet";
|
import { TrackSheet } from "./TrackSheet";
|
||||||
|
|
||||||
const Chromecast = !Platform.isTV ? require("./Chromecast") : null;
|
const Chromecast = !Platform.isTV ? require("./Chromecast") : null;
|
||||||
@@ -115,7 +116,10 @@ export const ItemContent: React.FC<ItemContentProps> = React.memo(
|
|||||||
<DownloadSingleItem item={item} size='large' />
|
<DownloadSingleItem item={item} size='large' />
|
||||||
)}
|
)}
|
||||||
{user?.Policy?.IsAdministrator && (
|
{user?.Policy?.IsAdministrator && (
|
||||||
<PlayInRemoteSessionButton item={item} size='large' />
|
<>
|
||||||
|
<PlayInRemoteSessionButton item={item} size='large' />
|
||||||
|
<RefreshMetadata item={item} />
|
||||||
|
</>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<PlayedStatus items={[item]} size='large' />
|
<PlayedStatus items={[item]} size='large' />
|
||||||
@@ -132,7 +136,10 @@ export const ItemContent: React.FC<ItemContentProps> = React.memo(
|
|||||||
<DownloadSingleItem item={item} size='large' />
|
<DownloadSingleItem item={item} size='large' />
|
||||||
)}
|
)}
|
||||||
{user?.Policy?.IsAdministrator && (
|
{user?.Policy?.IsAdministrator && (
|
||||||
<PlayInRemoteSessionButton item={item} size='large' />
|
<>
|
||||||
|
<PlayInRemoteSessionButton item={item} size='large' />
|
||||||
|
<RefreshMetadata item={item} />
|
||||||
|
</>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<PlayedStatus items={[item]} size='large' />
|
<PlayedStatus items={[item]} size='large' />
|
||||||
|
|||||||
38
components/RefreshMetadata.tsx
Normal file
38
components/RefreshMetadata.tsx
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
import type { BaseItemDto } from "@jellyfin/sdk/lib/generated-client";
|
||||||
|
import type { FC } from "react";
|
||||||
|
import { Platform, View, type ViewProps } from "react-native";
|
||||||
|
import { RoundButton } from "@/components/RoundButton";
|
||||||
|
import { useRefreshMetadata } from "@/hooks/useRefreshMetadata";
|
||||||
|
|
||||||
|
interface Props extends ViewProps {
|
||||||
|
item: BaseItemDto;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const RefreshMetadata: FC<Props> = ({ item, ...props }) => {
|
||||||
|
const { refreshMetadata, isRefreshing } = useRefreshMetadata(item);
|
||||||
|
|
||||||
|
if (Platform.OS === "ios") {
|
||||||
|
return (
|
||||||
|
<View {...props}>
|
||||||
|
<RoundButton
|
||||||
|
size='large'
|
||||||
|
icon='reload-outline'
|
||||||
|
onPress={refreshMetadata}
|
||||||
|
hapticFeedback={!isRefreshing}
|
||||||
|
/>
|
||||||
|
</View>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<View {...props}>
|
||||||
|
<RoundButton
|
||||||
|
size='large'
|
||||||
|
icon='reload-outline'
|
||||||
|
onPress={refreshMetadata}
|
||||||
|
hapticFeedback={!isRefreshing}
|
||||||
|
fillColor={isRefreshing ? "primary" : undefined}
|
||||||
|
/>
|
||||||
|
</View>
|
||||||
|
);
|
||||||
|
};
|
||||||
42
hooks/useRefreshMetadata.ts
Normal file
42
hooks/useRefreshMetadata.ts
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
import type { BaseItemDto } from "@jellyfin/sdk/lib/generated-client";
|
||||||
|
import { getItemRefreshApi } from "@jellyfin/sdk/lib/utils/api";
|
||||||
|
import { useMutation, useQueryClient } from "@tanstack/react-query";
|
||||||
|
import { useAtom } from "jotai";
|
||||||
|
import { useTranslation } from "react-i18next";
|
||||||
|
import { toast } from "sonner-native";
|
||||||
|
import { apiAtom } from "@/providers/JellyfinProvider";
|
||||||
|
|
||||||
|
export const useRefreshMetadata = (item: BaseItemDto) => {
|
||||||
|
const queryClient = useQueryClient();
|
||||||
|
const [api] = useAtom(apiAtom);
|
||||||
|
const { t } = useTranslation();
|
||||||
|
const type = "item";
|
||||||
|
|
||||||
|
const refreshMetadataMutation = useMutation({
|
||||||
|
mutationFn: async () => {
|
||||||
|
if (api && item.Id) {
|
||||||
|
await getItemRefreshApi(api).refreshItem({
|
||||||
|
itemId: item.Id,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
onSuccess: () => {
|
||||||
|
toast.success(t("metadata.refresh_triggered"));
|
||||||
|
queryClient.invalidateQueries({ queryKey: [type, item.Id] });
|
||||||
|
},
|
||||||
|
onError: (error) => {
|
||||||
|
console.error("Failed to refresh metadata:", error);
|
||||||
|
toast.error(t("metadata.refresh_failed"));
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const refreshMetadata = () => {
|
||||||
|
refreshMetadataMutation.mutate();
|
||||||
|
};
|
||||||
|
|
||||||
|
return {
|
||||||
|
refreshMetadata,
|
||||||
|
isRefreshing: refreshMetadataMutation.isPending,
|
||||||
|
refreshMetadataMutation,
|
||||||
|
};
|
||||||
|
};
|
||||||
@@ -528,5 +528,9 @@
|
|||||||
"library": "Library",
|
"library": "Library",
|
||||||
"custom_links": "Custom Links",
|
"custom_links": "Custom Links",
|
||||||
"favorites": "Favorites"
|
"favorites": "Favorites"
|
||||||
|
},
|
||||||
|
"metadata": {
|
||||||
|
"refresh_triggered": "Metadata refresh triggered",
|
||||||
|
"refresh_failed": "Failed to refresh metadata"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user