jellyfin element is amazing

This commit is contained in:
Violet Caulfield
2025-02-24 20:14:47 -06:00
parent e8721612bc
commit 68c2dfe351
3 changed files with 24 additions and 10 deletions

View File

@@ -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

View File

@@ -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<void> {
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);
})
})
});
});
}

View File

@@ -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);