diff --git a/packages/react/src/components/layout/SelectionFooter.tsx b/packages/react/src/components/layout/SelectionFooter.tsx index 77ed8daeb..467b71a21 100644 --- a/packages/react/src/components/layout/SelectionFooter.tsx +++ b/packages/react/src/components/layout/SelectionFooter.tsx @@ -1,5 +1,5 @@ import React, { Suspense, useState } from "react"; -import { useAtom, useAtomValue } from "jotai"; +import { useAtom, useAtomValue, useSetAtom } from "jotai"; import { Button } from "@/shadcn/ui/button"; import { Dialog, DialogContent } from "@/shadcn/ui/dialog"; import { @@ -29,6 +29,8 @@ import { userAtom } from "@/store/auth"; import { Link } from "react-router-dom"; import { LazyNewPlaylistDialog } from "../video/LazyNewPlaylistDialog"; import { useToast } from "@/shadcn/ui/use-toast"; +import { queueAtom } from "@/store/queue"; + const SelectedVideosModal = ({ isSmall, open, @@ -38,7 +40,7 @@ const SelectedVideosModal = ({ open: boolean; onOpenChange: (open: boolean) => void; }) => { - const { selectedVideos } = useVideoSelection(); + const { selectedVideos, setSelectedVideos } = useVideoSelection(); const getThumbnailSrc = (video: PlaceholderVideo) => { const size = isSmall ? "sm" : "md"; @@ -47,16 +49,40 @@ const SelectedVideosModal = ({ return ( - - {selectedVideos.map((video) => ( -
- -
-

{video.title}

+ + {selectedVideos.map((video, idx) => ( +
+ + + + +
+

{video.title}

{}

{/* what was i doing here again why is this block empty ^ */}
@@ -141,37 +167,7 @@ const SelectionFooter = () => { Open in Multiview - - - - - - setPage(1)}> -
- Add to Queue - - - - -
- Add to Playlist - - - - - - - - + @@ -263,7 +259,68 @@ const SelectionFooter = () => { ); }; -function PlaylistMenuItems() { +function SelectionModifyPlaylistMenu({ disabled }: { disabled: boolean }) { + const { t } = useTranslation(); + const { selectedVideos } = useVideoSelection(); + + const setQueue = useSetAtom(queueAtom); + const { toast } = useToast(); + + return ( + + + + + + { + setQueue((prev) => { + return [ + ...selectedVideos.filter( + (v) => v.type === "stream" || v.type === "clip", + ), + ...prev.filter( + (v) => !selectedVideos.find(({ id }) => id === v.id), + ), + ]; + }); + + toast({ + variant: "primary", + title: "Added to queue", + duration: 2000, + }); + }} + > +
+ Add to Queue + + + + +
+ Add to Playlist + + + + + + + + + ); +} + +function SelectionModifyPlaylistSubmenu() { const { t } = useTranslation(); const { toast } = useToast(); @@ -271,6 +328,8 @@ function PlaylistMenuItems() { onSuccess: () => { toast({ title: "Added to playlist", + duration: 2000, + variant: "primary", }); }, });