From fdb48fddf13cfeed79d62d79e03d7cd5e5951b0e Mon Sep 17 00:00:00 2001 From: will-hut <22407192+will-hut@users.noreply.github.com> Date: Tue, 26 Mar 2024 20:39:02 -0500 Subject: [PATCH 1/2] [feat] Create "Add current track" button in playlist view fix dependency list Add success toast --- src/i18n/locales/en.json | 1 + .../components/sidebar-playlist-list.tsx | 73 +++++++++++++++++-- 2 files changed, 67 insertions(+), 7 deletions(-) diff --git a/src/i18n/locales/en.json b/src/i18n/locales/en.json index b7965f778..39fa7c789 100644 --- a/src/i18n/locales/en.json +++ b/src/i18n/locales/en.json @@ -17,6 +17,7 @@ "setRating": "set rating", "toggleSmartPlaylistEditor": "toggle $t(entity.smartPlaylist) editor", "viewPlaylists": "view $t(entity.playlist_other)", + "addCurrentSong": "$t(common.add) $t(common.currentSong)", "openIn": { "lastfm": "Open in Last.fm", "musicbrainz": "Open in MusicBrainz" diff --git a/src/renderer/features/sidebar/components/sidebar-playlist-list.tsx b/src/renderer/features/sidebar/components/sidebar-playlist-list.tsx index 2592e1917..32624dd06 100644 --- a/src/renderer/features/sidebar/components/sidebar-playlist-list.tsx +++ b/src/renderer/features/sidebar/components/sidebar-playlist-list.tsx @@ -2,19 +2,19 @@ import { useCallback, useMemo, useState } from 'react'; import { Box, Flex, Group } from '@mantine/core'; import { useDebouncedValue } from '@mantine/hooks'; import { useTranslation } from 'react-i18next'; -import { RiAddBoxFill, RiAddCircleFill, RiPlayFill } from 'react-icons/ri'; +import { RiAddBoxFill, RiAddCircleFill, RiPlayFill, RiPlayListAddFill } from 'react-icons/ri'; import { generatePath } from 'react-router'; import { Link } from 'react-router-dom'; import { LibraryItem, Playlist } from '/@/renderer/api/types'; -import { Button, Text } from '/@/renderer/components'; +import { Button, Text, toast } from '/@/renderer/components'; import { usePlayQueueAdd } from '/@/renderer/features/player'; -import { usePlaylistList } from '/@/renderer/features/playlists'; +import { useAddToPlaylist, usePlaylistList } from '/@/renderer/features/playlists'; import { AppRoute } from '/@/renderer/router/routes'; import { Play } from '/@/renderer/types'; import AutoSizer from 'react-virtualized-auto-sizer'; import { FixedSizeList, ListChildComponentProps } from 'react-window'; import { useHideScrollbar } from '/@/renderer/hooks'; -import { useCurrentServer, useGeneralSettings } from '/@/renderer/store'; +import { useCurrentServer, useGeneralSettings, useCurrentSong } from '/@/renderer/store'; interface SidebarPlaylistListProps { data: ReturnType['data']; @@ -84,6 +84,24 @@ const PlaylistRow = ({ index, data, style }: ListChildComponentProps) => { right="0" spacing="sm" > + {!data?.items?.[index].rules && ( // hide button on smart playlists + + )} +