From e82ff1ff0ced3e3b2fa854f0b3c2a4f961ecba31 Mon Sep 17 00:00:00 2001 From: Prayag Prajapati Date: Sat, 14 Sep 2024 11:33:18 +0530 Subject: [PATCH] feat: show queue item from currently playing item in queueButton --- src/components/buttons/queueButton.tsx | 152 ++++++++++++------------ src/routeTree.gen.ts | 12 +- src/routes/_api/library/library.scss | 1 + src/routes/_api/login.tsx | 4 +- src/routes/_api/player/videoPlayer.scss | 37 +++--- 5 files changed, 105 insertions(+), 101 deletions(-) diff --git a/src/components/buttons/queueButton.tsx b/src/components/buttons/queueButton.tsx index fd5acf3..8d8d73e 100644 --- a/src/components/buttons/queueButton.tsx +++ b/src/components/buttons/queueButton.tsx @@ -34,7 +34,7 @@ const QueueButton = () => { const handlePlay = useMutation({ mutationKey: ["handlePlayIndex"], mutationFn: async ({ index }: { index: number }) => { - const result = playItemFromQueue(index, user.data?.Id); + const result = playItemFromQueue(index, user.data?.Id, api); return result; }, onSuccess: () => { @@ -76,82 +76,86 @@ const QueueButton = () => { position: "relative", }} > - {queueItems.map((item, index) => { - return ( - handlePlay.mutate({ index })} - key={item.Id} - > - - {item.Type === "Audio" - ? index + 1 - : item.IndexNumberEnd - ? `S${item.ParentIndexNumber}:E${item.IndexNumber} / ${item.IndexNumberEnd}` - : `S${item.ParentIndexNumber}:E${item.IndexNumber}`} - -
- {item.ImageTags?.Primary ? ( - {item.Name} - ) : item.AlbumPrimaryImageTag?.length > 0 ? ( - {item.Name} - ) : ( -
- {getTypeIcon(item.Type)} -
- )} - {index === currentItemIndex && ( - - equalizer - - )} -
-
- {item.SeriesName ? ( - <> - - {item.SeriesName} - - { + return ( + + handlePlay.mutate({ index: index + currentItemIndex }) + } + key={item.Id} + > + + {item.Type === "Audio" + ? index + 1 + : item.IndexNumberEnd + ? `S${item.ParentIndexNumber}:E${item.IndexNumber} / ${item.IndexNumberEnd}` + : `S${item.ParentIndexNumber}:E${item.IndexNumber}`} + +
+ {item.ImageTags?.Primary ? ( + {item.Name} + ) : item.AlbumPrimaryImageTag?.length > 0 ? ( + {item.Name} + ) : ( +
+ {getTypeIcon(item.Type)} +
+ )} + {index === 0 && ( + + equalizer + + )} +
+
+ {item.SeriesName ? ( + <> + + {item.SeriesName} + + + {item.Name} + + + ) : ( + {item.Name} - - ) : ( - - {item.Name} - - )} -
-
- ); - })} + )} +
+
+ ); + })} setButtonEl(e.currentTarget)}> diff --git a/src/routeTree.gen.ts b/src/routeTree.gen.ts index 2ec5f5d..e1158af 100644 --- a/src/routeTree.gen.ts +++ b/src/routeTree.gen.ts @@ -439,7 +439,7 @@ const ApiRouteChildren: ApiRouteChildren = { const ApiRouteWithChildren = ApiRoute._addFileChildren(ApiRouteChildren) -interface FileRoutesByFullPath { +export interface FileRoutesByFullPath { '/': typeof IndexRoute '': typeof ApiRouteWithChildren '/library': typeof ApiLibraryRouteWithChildren @@ -468,7 +468,7 @@ interface FileRoutesByFullPath { '/login/$userId/$userName': typeof ApiLoginUserIdUserNameRoute } -interface FileRoutesByTo { +export interface FileRoutesByTo { '/': typeof IndexRoute '': typeof ApiRouteWithChildren '/library': typeof ApiLibraryRouteWithChildren @@ -496,7 +496,8 @@ interface FileRoutesByTo { '/login/$userId/$userName': typeof ApiLoginUserIdUserNameRoute } -interface FileRoutesById { +export interface FileRoutesById { + __root__: typeof rootRoute '/': typeof IndexRoute '/_api': typeof ApiRouteWithChildren '/_api/library': typeof ApiLibraryRouteWithChildren @@ -525,7 +526,7 @@ interface FileRoutesById { '/_api/login/$userId/$userName': typeof ApiLoginUserIdUserNameRoute } -interface FileRouteTypes { +export interface FileRouteTypes { fileRoutesByFullPath: FileRoutesByFullPath fullPaths: | '/' @@ -582,6 +583,7 @@ interface FileRouteTypes { | '/search' | '/login/$userId/$userName' id: + | '__root__' | '/' | '/_api' | '/_api/library' @@ -611,7 +613,7 @@ interface FileRouteTypes { fileRoutesById: FileRoutesById } -interface RootRouteChildren { +export interface RootRouteChildren { IndexRoute: typeof IndexRoute ApiRoute: typeof ApiRouteWithChildren ErrorCodeRoute: typeof ErrorCodeRoute diff --git a/src/routes/_api/library/library.scss b/src/routes/_api/library/library.scss index 3f418a1..bfb0991 100644 --- a/src/routes/_api/library/library.scss +++ b/src/routes/_api/library/library.scss @@ -139,6 +139,7 @@ flex-basis: 14%; } width: 14%; + flex-basis: 14%; height: fit-content; display: inline-flex; flex-direction: row; diff --git a/src/routes/_api/login.tsx b/src/routes/_api/login.tsx index 63f82b7..d71eed1 100644 --- a/src/routes/_api/login.tsx +++ b/src/routes/_api/login.tsx @@ -7,7 +7,7 @@ export const Route = createFileRoute("/_api/login")({ const api = context.api; if (!api) { console.info("Awaiting Api generation."); - return; + throw redirect({ to: "/login/manual" }); } const publicUsers = (await getUserApi(api).getPublicUsers()).data; if (publicUsers.length > 0) { @@ -16,4 +16,4 @@ export const Route = createFileRoute("/_api/login")({ throw redirect({ to: "/login/manual" }); } }, -}); \ No newline at end of file +}); diff --git a/src/routes/_api/player/videoPlayer.scss b/src/routes/_api/player/videoPlayer.scss index 0f28c29..3b9fdbb 100644 --- a/src/routes/_api/player/videoPlayer.scss +++ b/src/routes/_api/player/videoPlayer.scss @@ -1,4 +1,3 @@ - .video { &-osd { opacity: 0; @@ -18,9 +17,9 @@ } gap: 0.5em; } - &-trick-bubble{ + &-trick-bubble { overflow: hidden; - border-radius: $border-radius-default; + border-radius: $border-radius-default; } } &-osd-visible { @@ -36,7 +35,7 @@ bottom: 0; overflow: hidden; } - &-volume-indicator{ + &-volume-indicator { display: flex; flex-direction: column; width: 12em; @@ -50,13 +49,12 @@ right: 2em; z-index: 10; border-radius: 2em; - .material-symbols-rounded{ + .material-symbols-rounded { font-size: 3em; - --fill:1; + --fill: 1; } } } - video { &::-webkit-media-text-track-display { overflow: visible !important; @@ -69,7 +67,6 @@ video { text-shadow: 0 2px 10px rgb(0 0 0 / 0.8); } } - .video-player { background: black; position: absolute; @@ -77,7 +74,7 @@ video { height: 100vh; top: 0; left: 0; - &-osd{ + &-osd { position: absolute; width: 100vw; height: 100vh; @@ -90,17 +87,17 @@ video { justify-content: space-between; padding: 1em 2em; background: linear-gradient(to top, rgb(0 0 0 / 0.7) 5vh, transparent 26vh 90vh, rgb(0 0 0 / 0.7)); - &.hovering{ + &.hovering { cursor: default; } - &-controls{ - &-progress{ + &-controls { + &-progress { display: flex; flex-direction: column; gap: 0.2em; align-items: stretch; justify-content: center; - &-text{ + &-text { display: flex; align-items: stretch; justify-content: space-between; @@ -113,12 +110,12 @@ video { align-items: center; } } - .MuiSlider-valueLabel { - padding: 0; - background: transparent; - overflow: hidden; - border-radius: $border-radius-default; - border: 1.2px solid rgb(255 255 255 / 0.1); - } + .MuiSlider-valueLabel { + padding: 0; + background: transparent; + overflow: hidden; + border-radius: $border-radius-default; + border: 1.2px solid rgb(255 255 255 / 0.1); + } } } \ No newline at end of file