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' }));
}
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',

24
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}
/>
</>

8
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}

Loading…
Cancel
Save