mirror of
https://github.com/streamyfin/streamyfin.git
synced 2026-01-15 23:59:08 +00:00
Some checks failed
🤖 Android APK Build / 🏗️ Build Android APK (push) Has been cancelled
🤖 iOS IPA Build / 🏗️ Build iOS IPA (push) Has been cancelled
🔒 Lockfile Consistency Check / 🔍 Check bun.lock and package.json consistency (push) Has been cancelled
🛡️ CodeQL Analysis / 🔎 Analyze with CodeQL (javascript-typescript) (push) Has been cancelled
🏷️🔀Merge Conflict Labeler / 🏷️ Labeling Merge Conflicts (push) Has been cancelled
🕒 Handle Stale Issues / 🗑️ Cleanup Stale Issues (push) Has been cancelled
63 lines
1.6 KiB
TypeScript
63 lines
1.6 KiB
TypeScript
import type { BaseItemDto } from "@jellyfin/sdk/lib/generated-client/models";
|
|
import { useQueryClient } from "@tanstack/react-query";
|
|
import type React from "react";
|
|
import { View, type ViewProps } from "react-native";
|
|
import { useMarkAsPlayed } from "@/hooks/useMarkAsPlayed";
|
|
import { RoundButton } from "./RoundButton";
|
|
|
|
interface Props extends ViewProps {
|
|
items: BaseItemDto[];
|
|
size?: "default" | "large";
|
|
}
|
|
|
|
export const PlayedStatus: React.FC<Props> = ({ items, ...props }) => {
|
|
const queryClient = useQueryClient();
|
|
|
|
const _invalidateQueries = () => {
|
|
items.forEach((item) => {
|
|
queryClient.invalidateQueries({
|
|
queryKey: ["item", item.Id],
|
|
});
|
|
});
|
|
queryClient.invalidateQueries({
|
|
queryKey: ["resumeItems"],
|
|
});
|
|
queryClient.invalidateQueries({
|
|
queryKey: ["continueWatching"],
|
|
});
|
|
queryClient.invalidateQueries({
|
|
queryKey: ["nextUp-all"],
|
|
});
|
|
queryClient.invalidateQueries({
|
|
queryKey: ["nextUp"],
|
|
});
|
|
queryClient.invalidateQueries({
|
|
queryKey: ["episodes"],
|
|
});
|
|
queryClient.invalidateQueries({
|
|
queryKey: ["seasons"],
|
|
});
|
|
queryClient.invalidateQueries({
|
|
queryKey: ["home"],
|
|
});
|
|
};
|
|
|
|
const allPlayed = items.every((item) => item.UserData?.Played);
|
|
|
|
const markAsPlayedStatus = useMarkAsPlayed(items);
|
|
|
|
return (
|
|
<View {...props}>
|
|
<RoundButton
|
|
fillColor={allPlayed ? "primary" : undefined}
|
|
icon={allPlayed ? "checkmark" : "checkmark"}
|
|
onPress={async () => {
|
|
console.log(allPlayed);
|
|
await markAsPlayedStatus(!allPlayed);
|
|
}}
|
|
size={props.size}
|
|
/>
|
|
</View>
|
|
);
|
|
};
|