diff --git a/README.md b/README.md index a6ef26cb..cadec6a3 100644 --- a/README.md +++ b/README.md @@ -118,7 +118,7 @@ This is undoubtedly a passion project of [mine](https://github.com/anultraviolet - Coming Soon™️ ## 🙏 Special Thanks To -- The [Jellyfin Team](https://jellyfin.org/) for their amazing server software, SDKs, and documentation +- The [Jellyfin Team](https://jellyfin.org/) for making this possible with their software, SDKs, and unequivocal helpfulness - All contributors of [Finamp](https://github.com/jmshrv/finamp). *Jellify* draws inspiration and wisdom from it, and is another fantastic music app for Jellyfin - The folks in the [Margelo Community Discord](https://discord.com/invite/6CSHz2qAvA) for their assistance - Tony, Trevor, [Laine](https://github.com/lainie-ftw) and [Jordan](https://github.com/jordanbleu) for their testing and feedback from the early stages of development diff --git a/api/mutations/functions/item.ts b/api/mutations/functions/item.ts index 4294eb72..87851db9 100644 --- a/api/mutations/functions/item.ts +++ b/api/mutations/functions/item.ts @@ -1,6 +1,7 @@ import Client from "../../../api/client"; import { BaseItemDto } from "@jellyfin/sdk/lib/generated-client/models"; -import { getPlaystateApi } from "@jellyfin/sdk/lib/utils/api"; +import { getItemsApi, getPlaystateApi, getUserLibraryApi } from "@jellyfin/sdk/lib/utils/api"; +import { isUndefined } from "lodash"; /** * Manually marks an item as played. @@ -15,16 +16,24 @@ import { getPlaystateApi } from "@jellyfin/sdk/lib/utils/api"; */ export async function markItemPlayed(item: BaseItemDto) : Promise { return new Promise((resolve, reject) => { - getPlaystateApi(Client.api!) - .markPlayedItem({ + + if (isUndefined(Client.api) || isUndefined(Client.user)) + return reject("Client instance not set") + + getItemsApi(Client.api) + .updateItemUserData({ itemId: item.Id!, - userId: Client.user!.id + userId: Client.user.id, + updateUserItemDataDto: { + LastPlayedDate: new Date().getUTCDate().toLocaleString(), + Played: true, + } }) - .then((response) => { + .then(({ data }) => { resolve() }) - .catch(error => { + .catch((error) => { reject(error); - }) - }) + }); + }); } \ No newline at end of file diff --git a/player/provider.tsx b/player/provider.tsx index 3019f32b..4bce893b 100644 --- a/player/provider.tsx +++ b/player/provider.tsx @@ -21,6 +21,8 @@ import { Section } from "../components/Player/types"; import { Queue } from "./types/queue-item"; import * as Burnt from "burnt"; +import { markItemPlayed } from "@/api/mutations/functions/item"; +import { BaseItemDto } from "@jellyfin/sdk/lib/generated-client/models"; interface PlayerContext { initialized: boolean; @@ -231,7 +233,10 @@ const PlayerContextInitializer = () => { }, onSuccess: async (data, mutation: QueueMutation) => { setIsSkipping(false); - await play(mutation.index) + await play(mutation.index); + + if (typeof(mutation.queue) === 'object') + await markItemPlayed(queue as BaseItemDto); }, onError: async () => { setIsSkipping(false);