From 3a50053ec5308b77b4ecb2258bf306b18da54384 Mon Sep 17 00:00:00 2001 From: jeffvli Date: Mon, 13 Dec 2021 19:50:33 -0800 Subject: [PATCH] Add support to music type on cards --- src/components/card/Card.tsx | 4 ++-- src/components/dashboard/Dashboard.tsx | 24 ++++++++++++------- .../scrollingmenu/ScrollingMenu.tsx | 8 +++++-- 3 files changed, 24 insertions(+), 12 deletions(-) diff --git a/src/components/card/Card.tsx b/src/components/card/Card.tsx index cee15bd..fd3f9bf 100644 --- a/src/components/card/Card.tsx +++ b/src/components/card/Card.tsx @@ -82,7 +82,7 @@ const Card = ({ notifyToast('info', getPlayedSongsNotification({ ...songs.count, type: 'play' })); } - if (playClick.type === 'album') { + if (playClick.type === 'album' || playClick.type === 'music') { const res = await apiController({ serverType: config.serverType, endpoint: 'getAlbum', @@ -143,7 +143,7 @@ const Card = ({ notifyToast('info', getPlayedSongsNotification({ ...songs.count, type: 'add' })); } - if (playClick.type === 'album') { + if (playClick.type === 'album' || playClick.type === 'music') { const res = await apiController({ serverType: config.serverType, endpoint: 'getAlbum', diff --git a/src/components/dashboard/Dashboard.tsx b/src/components/dashboard/Dashboard.tsx index 376b705..2882997 100644 --- a/src/components/dashboard/Dashboard.tsx +++ b/src/components/dashboard/Dashboard.tsx @@ -10,6 +10,7 @@ import { useAppDispatch, useAppSelector } from '../../redux/hooks'; import { setStar } from '../../redux/playQueueSlice'; import { setActive } from '../../redux/albumSlice'; import { apiController } from '../../api/controller'; +import { Server } from '../../types'; const Dashboard = () => { const history = useHistory(); @@ -31,9 +32,13 @@ const Dashboard = () => { () => apiController({ serverType: config.serverType, - endpoint: 'getAlbums', - args: { type: 'recent', size: 20, offset: 0, musicFolderId: musicFolder }, - }) + endpoint: config.serverType === Server.Jellyfin ? 'getSongs' : 'getAlbums', + args: { type: 'recent', size: 20, offset: 0, order: 'desc', musicFolderId: musicFolder }, + }), + { + refetchOnWindowFocus: true, + refetchInterval: 30000, + } ); const { isLoading: isLoadingNewest, data: newestAlbums }: any = useQuery( @@ -61,9 +66,12 @@ const Dashboard = () => { () => apiController({ serverType: config.serverType, - endpoint: 'getAlbums', - args: { type: 'frequent', size: 20, offset: 0, musicFolderId: musicFolder }, - }) + endpoint: config.serverType === Server.Jellyfin ? 'getSongs' : 'getAlbums', + args: { type: 'frequent', size: 20, offset: 0, order: 'desc', musicFolderId: musicFolder }, + }), + { + refetchOnWindowFocus: true, + } ); const handleFavorite = async (rowData: any) => { @@ -180,7 +188,7 @@ const Dashboard = () => { history.push(`/library/album?sortType=recent`); }, 50); }} - type="album" + type="music" handleFavorite={handleFavorite} /> @@ -252,7 +260,7 @@ const Dashboard = () => { history.push(`/library/album?sortType=frequent`); }, 50); }} - type="album" + type="music" handleFavorite={handleFavorite} /> diff --git a/src/components/scrollingmenu/ScrollingMenu.tsx b/src/components/scrollingmenu/ScrollingMenu.tsx index 38b4fb9..e4f0110 100644 --- a/src/components/scrollingmenu/ScrollingMenu.tsx +++ b/src/components/scrollingmenu/ScrollingMenu.tsx @@ -88,13 +88,17 @@ const ScrollingMenu = ({ : item[cardSubtitle.property] } coverArt={item.image} - url={cardTitle.urlProperty ? `${cardTitle.prefix}/${item.id}` : undefined} + url={ + cardTitle.urlProperty + ? `${cardTitle.prefix}/${type === 'music' ? item.albumId : item.id}` + : undefined + } subUrl={ cardSubtitle.urlProperty ? `${cardSubtitle.prefix}/${item[cardSubtitle.urlProperty]}` : undefined } - playClick={{ type, id: item.id }} + playClick={{ type, id: type === 'music' ? item.albumId : item.id }} details={{ cacheType: type, ...item }} hasHoverButtons size={config.lookAndFeel.gridView.cardSize}