Browse Source

Add support to music type on cards

master
jeffvli 3 years ago
committed by Jeff
parent
commit
3a50053ec5
  1. 4
      src/components/card/Card.tsx
  2. 24
      src/components/dashboard/Dashboard.tsx
  3. 8
      src/components/scrollingmenu/ScrollingMenu.tsx

4
src/components/card/Card.tsx

@ -82,7 +82,7 @@ const Card = ({
notifyToast('info', getPlayedSongsNotification({ ...songs.count, type: 'play' })); notifyToast('info', getPlayedSongsNotification({ ...songs.count, type: 'play' }));
} }
if (playClick.type === 'album') { if (playClick.type === 'album' || playClick.type === 'music') {
const res = await apiController({ const res = await apiController({
serverType: config.serverType, serverType: config.serverType,
endpoint: 'getAlbum', endpoint: 'getAlbum',
@ -143,7 +143,7 @@ const Card = ({
notifyToast('info', getPlayedSongsNotification({ ...songs.count, type: 'add' })); notifyToast('info', getPlayedSongsNotification({ ...songs.count, type: 'add' }));
} }
if (playClick.type === 'album') { if (playClick.type === 'album' || playClick.type === 'music') {
const res = await apiController({ const res = await apiController({
serverType: config.serverType, serverType: config.serverType,
endpoint: 'getAlbum', endpoint: 'getAlbum',

24
src/components/dashboard/Dashboard.tsx

@ -10,6 +10,7 @@ import { useAppDispatch, useAppSelector } from '../../redux/hooks';
import { setStar } from '../../redux/playQueueSlice'; import { setStar } from '../../redux/playQueueSlice';
import { setActive } from '../../redux/albumSlice'; import { setActive } from '../../redux/albumSlice';
import { apiController } from '../../api/controller'; import { apiController } from '../../api/controller';
import { Server } from '../../types';
const Dashboard = () => { const Dashboard = () => {
const history = useHistory(); const history = useHistory();
@ -31,9 +32,13 @@ const Dashboard = () => {
() => () =>
apiController({ apiController({
serverType: config.serverType, serverType: config.serverType,
endpoint: 'getAlbums', endpoint: config.serverType === Server.Jellyfin ? 'getSongs' : 'getAlbums',
args: { type: 'recent', size: 20, offset: 0, musicFolderId: musicFolder }, args: { type: 'recent', size: 20, offset: 0, order: 'desc', musicFolderId: musicFolder },
}) }),
{
refetchOnWindowFocus: true,
refetchInterval: 30000,
}
); );
const { isLoading: isLoadingNewest, data: newestAlbums }: any = useQuery( const { isLoading: isLoadingNewest, data: newestAlbums }: any = useQuery(
@ -61,9 +66,12 @@ const Dashboard = () => {
() => () =>
apiController({ apiController({
serverType: config.serverType, serverType: config.serverType,
endpoint: 'getAlbums', endpoint: config.serverType === Server.Jellyfin ? 'getSongs' : 'getAlbums',
args: { type: 'frequent', size: 20, offset: 0, musicFolderId: musicFolder }, args: { type: 'frequent', size: 20, offset: 0, order: 'desc', musicFolderId: musicFolder },
}) }),
{
refetchOnWindowFocus: true,
}
); );
const handleFavorite = async (rowData: any) => { const handleFavorite = async (rowData: any) => {
@ -180,7 +188,7 @@ const Dashboard = () => {
history.push(`/library/album?sortType=recent`); history.push(`/library/album?sortType=recent`);
}, 50); }, 50);
}} }}
type="album" type="music"
handleFavorite={handleFavorite} handleFavorite={handleFavorite}
/> />
@ -252,7 +260,7 @@ const Dashboard = () => {
history.push(`/library/album?sortType=frequent`); history.push(`/library/album?sortType=frequent`);
}, 50); }, 50);
}} }}
type="album" type="music"
handleFavorite={handleFavorite} handleFavorite={handleFavorite}
/> />
</> </>

8
src/components/scrollingmenu/ScrollingMenu.tsx

@ -88,13 +88,17 @@ const ScrollingMenu = ({
: item[cardSubtitle.property] : item[cardSubtitle.property]
} }
coverArt={item.image} coverArt={item.image}
url={cardTitle.urlProperty ? `${cardTitle.prefix}/${item.id}` : undefined} url={
cardTitle.urlProperty
? `${cardTitle.prefix}/${type === 'music' ? item.albumId : item.id}`
: undefined
}
subUrl={ subUrl={
cardSubtitle.urlProperty cardSubtitle.urlProperty
? `${cardSubtitle.prefix}/${item[cardSubtitle.urlProperty]}` ? `${cardSubtitle.prefix}/${item[cardSubtitle.urlProperty]}`
: undefined : undefined
} }
playClick={{ type, id: item.id }} playClick={{ type, id: type === 'music' ? item.albumId : item.id }}
details={{ cacheType: type, ...item }} details={{ cacheType: type, ...item }}
hasHoverButtons hasHoverButtons
size={config.lookAndFeel.gridView.cardSize} size={config.lookAndFeel.gridView.cardSize}

Loading…
Cancel
Save