Use song-specific cover and add placeholder (#6)
This commit is contained in:
parent
cdbd3f8c7b
commit
fecaa2e6b8
5 changed files with 19 additions and 3 deletions
|
@ -604,6 +604,7 @@ const normalizeSong = (
|
||||||
duration: item.RunTimeTicks / 10000000,
|
duration: item.RunTimeTicks / 10000000,
|
||||||
genres: item.GenreItems.map((entry: any) => ({ id: entry.Id, name: entry.Name })),
|
genres: item.GenreItems.map((entry: any) => ({ id: entry.Id, name: entry.Name })),
|
||||||
id: item.Id,
|
id: item.Id,
|
||||||
|
imagePlaceholderUrl: getSongCoverArtUrl({ baseUrl: server.url, item, size: 1 }),
|
||||||
imageUrl: getSongCoverArtUrl({ baseUrl: server.url, item, size: imageSize || 300 }),
|
imageUrl: getSongCoverArtUrl({ baseUrl: server.url, item, size: imageSize || 300 }),
|
||||||
isFavorite: (item.UserData && item.UserData.IsFavorite) || false,
|
isFavorite: (item.UserData && item.UserData.IsFavorite) || false,
|
||||||
lastPlayedAt: null,
|
lastPlayedAt: null,
|
||||||
|
|
|
@ -452,10 +452,18 @@ const normalizeSong = (
|
||||||
): Song => {
|
): Song => {
|
||||||
const imageUrl = getCoverArtUrl({
|
const imageUrl = getCoverArtUrl({
|
||||||
baseUrl: server.url,
|
baseUrl: server.url,
|
||||||
coverArtId: item.albumId,
|
coverArtId: item.id,
|
||||||
credential: server.credential,
|
credential: server.credential,
|
||||||
size: imageSize || 300,
|
size: imageSize || 300,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const imagePlaceholderUrl = getCoverArtUrl({
|
||||||
|
baseUrl: server.url,
|
||||||
|
coverArtId: item.albumId,
|
||||||
|
credential: server.credential,
|
||||||
|
size: 1,
|
||||||
|
});
|
||||||
|
|
||||||
let id;
|
let id;
|
||||||
|
|
||||||
// Dynamically determine the id field based on whether or not the item is a playlist song
|
// Dynamically determine the id field based on whether or not the item is a playlist song
|
||||||
|
@ -481,6 +489,7 @@ const normalizeSong = (
|
||||||
duration: item.duration,
|
duration: item.duration,
|
||||||
genres: item.genres,
|
genres: item.genres,
|
||||||
id,
|
id,
|
||||||
|
imagePlaceholderUrl,
|
||||||
imageUrl,
|
imageUrl,
|
||||||
isFavorite: item.starred,
|
isFavorite: item.starred,
|
||||||
lastPlayedAt: item.playDate ? item.playDate : null,
|
lastPlayedAt: item.playDate ? item.playDate : null,
|
||||||
|
|
|
@ -174,6 +174,7 @@ export type Song = {
|
||||||
duration: number;
|
duration: number;
|
||||||
genres: Genre[];
|
genres: Genre[];
|
||||||
id: string;
|
id: string;
|
||||||
|
imagePlaceholderUrl: string | null;
|
||||||
imageUrl: string | null;
|
imageUrl: string | null;
|
||||||
isFavorite: boolean;
|
isFavorite: boolean;
|
||||||
lastPlayedAt: string | null;
|
lastPlayedAt: string | null;
|
||||||
|
|
|
@ -5,6 +5,7 @@ import { motion } from 'framer-motion';
|
||||||
import { RiAlbumFill } from 'react-icons/ri';
|
import { RiAlbumFill } from 'react-icons/ri';
|
||||||
import { generatePath } from 'react-router';
|
import { generatePath } from 'react-router';
|
||||||
import { Link } from 'react-router-dom';
|
import { Link } from 'react-router-dom';
|
||||||
|
import { SimpleImg } from 'react-simple-img';
|
||||||
import styled from 'styled-components';
|
import styled from 'styled-components';
|
||||||
import type { AlbumArtist, Artist } from '/@/renderer/api/types';
|
import type { AlbumArtist, Artist } from '/@/renderer/api/types';
|
||||||
import { Text } from '/@/renderer/components/text';
|
import { Text } from '/@/renderer/components/text';
|
||||||
|
@ -40,8 +41,10 @@ const MetadataWrapper = styled.div`
|
||||||
width: 100%;
|
width: 100%;
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const StyledImage = styled.img`
|
const StyledImage = styled(SimpleImg)`
|
||||||
object-fit: cover;
|
img {
|
||||||
|
object-fit: cover;
|
||||||
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
export const CombinedTitleCell = ({ value, rowIndex, node }: ICellRendererParams) => {
|
export const CombinedTitleCell = ({ value, rowIndex, node }: ICellRendererParams) => {
|
||||||
|
@ -78,6 +81,7 @@ export const CombinedTitleCell = ({ value, rowIndex, node }: ICellRendererParams
|
||||||
<StyledImage
|
<StyledImage
|
||||||
alt="cover"
|
alt="cover"
|
||||||
height={(node.rowHeight || 40) - 10}
|
height={(node.rowHeight || 40) - 10}
|
||||||
|
placeholder={value.imagePlaceholderUrl || 'var(--placeholder-bg)'}
|
||||||
src={value.imageUrl}
|
src={value.imageUrl}
|
||||||
style={{}}
|
style={{}}
|
||||||
width={(node.rowHeight || 40) - 10}
|
width={(node.rowHeight || 40) - 10}
|
||||||
|
|
|
@ -217,6 +217,7 @@ const tableColumns: { [key: string]: ColDef } = {
|
||||||
? {
|
? {
|
||||||
albumArtists: params.data?.albumArtists,
|
albumArtists: params.data?.albumArtists,
|
||||||
artists: params.data?.artists,
|
artists: params.data?.artists,
|
||||||
|
imagePlaceholderUrl: params.data?.imagePlaceholderUrl,
|
||||||
imageUrl: params.data?.imageUrl,
|
imageUrl: params.data?.imageUrl,
|
||||||
name: params.data?.name,
|
name: params.data?.name,
|
||||||
rowHeight: params.node?.rowHeight,
|
rowHeight: params.node?.rowHeight,
|
||||||
|
|
Reference in a new issue