mirror of
https://github.com/jeffvli/feishin.git
synced 2026-05-08 21:10:12 +02:00
handle favorite/update in similarArtists
This commit is contained in:
@@ -37,6 +37,8 @@ const getPeople = (item: AlbumOrSong): null | Record<string, RelatedArtist[]> =>
|
||||
imageId: null,
|
||||
imageUrl: null,
|
||||
name: person.Name,
|
||||
userFavorite: false,
|
||||
userRating: null,
|
||||
};
|
||||
|
||||
if (key in participants) {
|
||||
@@ -148,6 +150,8 @@ const normalizeSong = (
|
||||
imageId: entry.Id,
|
||||
imageUrl: null,
|
||||
name: entry.Name,
|
||||
userFavorite: false,
|
||||
userRating: null,
|
||||
})),
|
||||
albumId: item.AlbumId || `dummy/${item.Id}`,
|
||||
artistName: item?.ArtistItems?.[0]?.Name || item?.AlbumArtists?.[0]?.Name,
|
||||
@@ -157,6 +161,8 @@ const normalizeSong = (
|
||||
imageId: null,
|
||||
imageUrl: null,
|
||||
name: entry.Name,
|
||||
userFavorite: false,
|
||||
userRating: null,
|
||||
}),
|
||||
),
|
||||
bitDepth: null,
|
||||
@@ -232,6 +238,8 @@ const normalizeAlbum = (
|
||||
imageId: entry.Id,
|
||||
imageUrl: null,
|
||||
name: entry.Name,
|
||||
userFavorite: false,
|
||||
userRating: null,
|
||||
})) || [],
|
||||
artists: (item.ArtistItems?.length ? item.ArtistItems : item.AlbumArtists)?.map(
|
||||
(entry) => ({
|
||||
@@ -239,6 +247,8 @@ const normalizeAlbum = (
|
||||
imageId: entry.Id,
|
||||
imageUrl: null,
|
||||
name: entry.Name,
|
||||
userFavorite: false,
|
||||
userRating: null,
|
||||
}),
|
||||
),
|
||||
comment: null,
|
||||
@@ -295,6 +305,8 @@ const normalizeAlbumArtist = (
|
||||
imageId: getAlbumArtistImageId(entry),
|
||||
imageUrl: null,
|
||||
name: entry.Name,
|
||||
userFavorite: entry.UserData?.IsFavorite || false,
|
||||
userRating: null,
|
||||
}),
|
||||
) || [];
|
||||
|
||||
|
||||
@@ -51,6 +51,8 @@ const getArtists = (
|
||||
imageId: null,
|
||||
imageUrl: null,
|
||||
name: item.name,
|
||||
userFavorite: false,
|
||||
userRating: null,
|
||||
}));
|
||||
|
||||
if (role === 'albumartist') {
|
||||
@@ -67,6 +69,8 @@ const getArtists = (
|
||||
imageId: null,
|
||||
imageUrl: null,
|
||||
name: artist.name,
|
||||
userFavorite: false,
|
||||
userRating: null,
|
||||
};
|
||||
|
||||
if (subRoles.has(artist.subRole)) {
|
||||
@@ -89,12 +93,28 @@ const getArtists = (
|
||||
|
||||
if (albumArtists === undefined) {
|
||||
albumArtists = [
|
||||
{ id: item.albumArtistId, imageId: null, imageUrl: null, name: item.albumArtist },
|
||||
{
|
||||
id: item.albumArtistId,
|
||||
imageId: null,
|
||||
imageUrl: null,
|
||||
name: item.albumArtist,
|
||||
userFavorite: false,
|
||||
userRating: null,
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
if (artists === undefined) {
|
||||
artists = [{ id: item.artistId, imageId: null, imageUrl: null, name: item.artist }];
|
||||
artists = [
|
||||
{
|
||||
id: item.artistId,
|
||||
imageId: null,
|
||||
imageUrl: null,
|
||||
name: item.artist,
|
||||
userFavorite: false,
|
||||
userRating: null,
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
return { albumArtists, artists, participants };
|
||||
@@ -304,6 +324,8 @@ const normalizeAlbumArtist = (
|
||||
songCount = item.songCount;
|
||||
}
|
||||
|
||||
console.log('similarArtists', item.similarArtists);
|
||||
|
||||
return {
|
||||
_itemType: LibraryItem.ALBUM_ARTIST,
|
||||
_serverId: server?.id || 'unknown',
|
||||
@@ -335,7 +357,9 @@ const normalizeAlbumArtist = (
|
||||
imageId: null,
|
||||
imageUrl: artist?.artistImageUrl?.replace(/\?size=\d+/, '') || null,
|
||||
name: artist.name,
|
||||
})) || null,
|
||||
userFavorite: Boolean(artist.starred) || false,
|
||||
userRating: artist.userRating || null,
|
||||
})) || [],
|
||||
songCount,
|
||||
userFavorite: item.starred || false,
|
||||
userRating: item.rating || null,
|
||||
|
||||
@@ -27,6 +27,8 @@ const getArtistList = (
|
||||
imageId: null,
|
||||
imageUrl: null,
|
||||
name: item.name,
|
||||
userFavorite: false,
|
||||
userRating: null,
|
||||
}))
|
||||
: [
|
||||
{
|
||||
@@ -34,6 +36,8 @@ const getArtistList = (
|
||||
imageId: null,
|
||||
imageUrl: null,
|
||||
name: artistName || '',
|
||||
userFavorite: false,
|
||||
userRating: null,
|
||||
},
|
||||
];
|
||||
};
|
||||
@@ -55,6 +59,8 @@ const getParticipants = (
|
||||
imageId: null,
|
||||
imageUrl: null,
|
||||
name: contributor.artist.name || '',
|
||||
userFavorite: false,
|
||||
userRating: null,
|
||||
};
|
||||
|
||||
const role = contributor.subRole
|
||||
@@ -178,8 +184,16 @@ const normalizeSong = (
|
||||
|
||||
const normalizeAlbumArtist = (
|
||||
item:
|
||||
| z.infer<typeof ssType._response.albumArtist>
|
||||
| z.infer<typeof ssType._response.artistListEntry>,
|
||||
| (z.infer<typeof ssType._response.albumArtist> & {
|
||||
similarArtists?: z.infer<
|
||||
typeof ssType._response.artistInfo
|
||||
>['artistInfo']['similarArtist'];
|
||||
})
|
||||
| (z.infer<typeof ssType._response.artistListEntry> & {
|
||||
similarArtists?: z.infer<
|
||||
typeof ssType._response.artistInfo
|
||||
>['artistInfo']['similarArtist'];
|
||||
}),
|
||||
server?: null | ServerListItemWithCredential,
|
||||
): AlbumArtist => {
|
||||
return {
|
||||
@@ -197,7 +211,15 @@ const normalizeAlbumArtist = (
|
||||
mbz: null,
|
||||
name: item.name,
|
||||
playCount: null,
|
||||
similarArtists: [],
|
||||
similarArtists:
|
||||
item.similarArtists?.map((artist) => ({
|
||||
id: artist.id,
|
||||
imageId: null,
|
||||
imageUrl: null,
|
||||
name: artist.name,
|
||||
userFavorite: Boolean(artist.starred) || false,
|
||||
userRating: artist.userRating || null,
|
||||
})) || [],
|
||||
songCount: null,
|
||||
userFavorite: Boolean(item.starred) || false,
|
||||
userRating: null,
|
||||
|
||||
@@ -236,6 +236,8 @@ const artistInfo = z.object({
|
||||
coverArt: z.string().optional(),
|
||||
id: z.string(),
|
||||
name: z.string(),
|
||||
starred: z.string().optional(),
|
||||
userRating: z.number().optional(),
|
||||
}),
|
||||
),
|
||||
smallImageUrl: z.string().optional(),
|
||||
|
||||
@@ -356,6 +356,8 @@ export type RelatedArtist = {
|
||||
imageId: null | string;
|
||||
imageUrl: null | string;
|
||||
name: string;
|
||||
userFavorite: boolean;
|
||||
userRating: null | number;
|
||||
};
|
||||
|
||||
export type Song = {
|
||||
|
||||
Reference in New Issue
Block a user