From dfe5c96faa3ebbc4f2b93dd0ca717fde83d11593 Mon Sep 17 00:00:00 2001 From: Violet Caulfield Date: Mon, 27 Jan 2025 19:34:30 -0600 Subject: [PATCH] getting ready to add that same reordering to playlists --- api/mutations/functions/playlists.ts | 13 +++++ api/queries/functions/playlists.ts | 1 - components/Player/screens/queue.tsx | 35 +++++-------- components/Playlist/component.tsx | 76 ++++++++++++++-------------- 4 files changed, 64 insertions(+), 61 deletions(-) create mode 100644 api/mutations/functions/playlists.ts diff --git a/api/mutations/functions/playlists.ts b/api/mutations/functions/playlists.ts new file mode 100644 index 00000000..af6159a1 --- /dev/null +++ b/api/mutations/functions/playlists.ts @@ -0,0 +1,13 @@ +import Client from "@/api/client"; +import { getPlaylistsApi } from "@jellyfin/sdk/lib/utils/api"; + + + +export async function reorderPlaylist(playlistId: string, itemId: string, to: number) { + return getPlaylistsApi(Client.api!) + .moveItem({ + playlistId, + itemId, + newIndex: to + }); +} \ No newline at end of file diff --git a/api/queries/functions/playlists.ts b/api/queries/functions/playlists.ts index 92646b82..2a33bcd6 100644 --- a/api/queries/functions/playlists.ts +++ b/api/queries/functions/playlists.ts @@ -1,5 +1,4 @@ import Client from "../../client"; -import { Api } from "@jellyfin/sdk"; import { BaseItemDto, ItemSortBy, SortOrder } from "@jellyfin/sdk/lib/generated-client/models"; import { getItemsApi } from "@jellyfin/sdk/lib/utils/api"; diff --git a/components/Player/screens/queue.tsx b/components/Player/screens/queue.tsx index 0ce850e2..09e63d58 100644 --- a/components/Player/screens/queue.tsx +++ b/components/Player/screens/queue.tsx @@ -45,29 +45,18 @@ export default function Queue({ navigation }: { navigation: NativeStackNavigatio const index = getIndex(); return ( - ( - { - - }} /> - )} - > - - track.item)} - index={getIndex()} - showArtwork - onPress={() => { - useSkip.mutate(index); - }} - onLongPress={drag} - isNested - /> - + track.item)} + index={getIndex()} + showArtwork + onPress={() => { + useSkip.mutate(index); + }} + onLongPress={drag} + isNested + /> ) }} /> diff --git a/components/Playlist/component.tsx b/components/Playlist/component.tsx index f1375934..9cf96dbd 100644 --- a/components/Playlist/component.tsx +++ b/components/Playlist/component.tsx @@ -33,44 +33,46 @@ export default function Playlist({ ]); return ( - - - + ( + + -

{ playlist.Name ?? "Untitled Playlist" }

-
{ playlist.ProductionYear?.toString() ?? "" }
-
- { +

{ playlist.Name ?? "Untitled Playlist" }

+
{ playlist.ProductionYear?.toString() ?? "" }
+
+ )} + numColumns={1} + renderItem={({ item: track, index }) => { - return ( - - ) - - }}/> - - - - Total Runtime: - - { playlist.RunTimeTicks } - -
+ return ( + + ) + }} + ListFooterComponent={() => ( + + + Total Runtime: + + { playlist.RunTimeTicks } + + )} + /> ) } \ No newline at end of file