mirror of
https://github.com/jeffvli/feishin.git
synced 2026-05-07 04:20:12 +02:00
refactor domain types to rename itemType
This commit is contained in:
@@ -15,8 +15,8 @@ const hasRequiredDragProperties = (
|
||||
item !== null &&
|
||||
'id' in item &&
|
||||
typeof (item as any).id === 'string' &&
|
||||
'itemType' in item &&
|
||||
typeof (item as any).itemType === 'string' &&
|
||||
'_itemType' in item &&
|
||||
typeof (item as any)._itemType === 'string' &&
|
||||
'_serverId' in item &&
|
||||
typeof (item as any)._serverId === 'string'
|
||||
);
|
||||
|
||||
@@ -87,7 +87,7 @@ export const useDefaultItemListControls = () => {
|
||||
rangeItem &&
|
||||
typeof rangeItem === 'object' &&
|
||||
'_serverId' in rangeItem &&
|
||||
'itemType' in rangeItem
|
||||
'_itemType' in rangeItem
|
||||
) {
|
||||
const rangeRowId = internalState.extractRowId(rangeItem);
|
||||
if (rangeRowId) {
|
||||
|
||||
@@ -73,15 +73,15 @@ export interface ItemListStateActions {
|
||||
}
|
||||
|
||||
export interface ItemListStateItem {
|
||||
_itemType: LibraryItem;
|
||||
_serverId: string;
|
||||
id: string;
|
||||
itemType: LibraryItem;
|
||||
}
|
||||
|
||||
export type ItemListStateItemWithRequiredProperties = Record<string, unknown> & {
|
||||
_itemType: LibraryItem;
|
||||
_serverId: string;
|
||||
id: string;
|
||||
itemType: LibraryItem;
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -36,8 +36,8 @@ export const ActionsColumn = (props: ItemTableListInnerColumn) => {
|
||||
color: 'muted',
|
||||
size: 'md',
|
||||
}}
|
||||
onDoubleClick={handleActionDoubleClick}
|
||||
onClick={handleActionClick}
|
||||
onDoubleClick={handleActionDoubleClick}
|
||||
size="xs"
|
||||
variant="subtle"
|
||||
/>
|
||||
|
||||
@@ -70,8 +70,8 @@ const hasRequiredStateItemProperties = (
|
||||
typeof (item as any).id === 'string' &&
|
||||
'_serverId' in item &&
|
||||
typeof (item as any)._serverId === 'string' &&
|
||||
'itemType' in item &&
|
||||
typeof (item as any).itemType === 'string' &&
|
||||
'_itemType' in item &&
|
||||
typeof (item as any)._itemType === 'string' &&
|
||||
'rowId' in item &&
|
||||
typeof (item as any).rowId === 'string'
|
||||
);
|
||||
@@ -1126,7 +1126,7 @@ export const ItemTableList = ({
|
||||
typeof item === 'object' &&
|
||||
item !== null &&
|
||||
'_serverId' in item &&
|
||||
'itemType' in item
|
||||
'_itemType' in item
|
||||
) {
|
||||
return item as ItemListStateItemWithRequiredProperties;
|
||||
}
|
||||
|
||||
@@ -227,6 +227,7 @@ const normalizeSong = (
|
||||
}
|
||||
|
||||
return {
|
||||
_itemType: LibraryItem.SONG,
|
||||
_serverId: server?.id || '',
|
||||
_serverType: ServerType.JELLYFIN,
|
||||
album: item.Album,
|
||||
@@ -265,15 +266,16 @@ const normalizeSong = (
|
||||
}
|
||||
: null,
|
||||
genres: item.GenreItems?.map((entry) => ({
|
||||
_itemType: LibraryItem.GENRE,
|
||||
_serverId: server?.id || '',
|
||||
_serverType: ServerType.JELLYFIN,
|
||||
id: entry.Id,
|
||||
imageUrl: null,
|
||||
itemType: LibraryItem.GENRE,
|
||||
name: entry.Name,
|
||||
})),
|
||||
id: item.Id,
|
||||
imagePlaceholderUrl: null,
|
||||
imageUrl: getSongCoverArtUrl({ baseUrl: server?.url || '', item, size: imageSize || 100 }),
|
||||
itemType: LibraryItem.SONG,
|
||||
lastPlayedAt: null,
|
||||
lyrics: null,
|
||||
mbzRecordingId: null,
|
||||
@@ -307,6 +309,7 @@ const normalizeAlbum = (
|
||||
imageSize?: number,
|
||||
): Album => {
|
||||
return {
|
||||
_itemType: LibraryItem.ALBUM,
|
||||
_serverId: server?.id || '',
|
||||
_serverType: ServerType.JELLYFIN,
|
||||
albumArtist: item.AlbumArtist,
|
||||
@@ -327,9 +330,11 @@ const normalizeAlbum = (
|
||||
duration: item.RunTimeTicks / 10000,
|
||||
explicitStatus: null,
|
||||
genres: item.GenreItems?.map((entry) => ({
|
||||
_itemType: LibraryItem.GENRE,
|
||||
_serverId: server?.id || '',
|
||||
_serverType: ServerType.JELLYFIN,
|
||||
id: entry.Id,
|
||||
imageUrl: null,
|
||||
itemType: LibraryItem.GENRE,
|
||||
name: entry.Name,
|
||||
})),
|
||||
id: item.Id,
|
||||
@@ -340,7 +345,6 @@ const normalizeAlbum = (
|
||||
size: imageSize || 300,
|
||||
}),
|
||||
isCompilation: null,
|
||||
itemType: LibraryItem.ALBUM,
|
||||
lastPlayedAt: null,
|
||||
mbzId: item.ProviderIds?.MusicBrainzAlbum || null,
|
||||
name: item.Name,
|
||||
@@ -383,6 +387,7 @@ const normalizeAlbumArtist = (
|
||||
) || [];
|
||||
|
||||
return {
|
||||
_itemType: LibraryItem.ALBUM_ARTIST,
|
||||
_serverId: server?.id || '',
|
||||
_serverType: ServerType.JELLYFIN,
|
||||
albumCount: item.AlbumCount ?? null,
|
||||
@@ -390,9 +395,11 @@ const normalizeAlbumArtist = (
|
||||
biography: item.Overview || null,
|
||||
duration: item.RunTimeTicks / 10000,
|
||||
genres: item.GenreItems?.map((entry) => ({
|
||||
_itemType: LibraryItem.GENRE,
|
||||
_serverId: server?.id || '',
|
||||
_serverType: ServerType.JELLYFIN,
|
||||
id: entry.Id,
|
||||
imageUrl: null,
|
||||
itemType: LibraryItem.GENRE,
|
||||
name: entry.Name,
|
||||
})),
|
||||
id: item.Id,
|
||||
@@ -401,7 +408,6 @@ const normalizeAlbumArtist = (
|
||||
item,
|
||||
size: imageSize || 300,
|
||||
}),
|
||||
itemType: LibraryItem.ALBUM_ARTIST,
|
||||
lastPlayedAt: null,
|
||||
mbz: item.ProviderIds?.MusicBrainzArtist || null,
|
||||
name: item.Name,
|
||||
@@ -427,20 +433,22 @@ const normalizePlaylist = (
|
||||
const imagePlaceholderUrl = null;
|
||||
|
||||
return {
|
||||
_itemType: LibraryItem.PLAYLIST,
|
||||
_serverId: server?.id || '',
|
||||
_serverType: ServerType.JELLYFIN,
|
||||
description: item.Overview || null,
|
||||
duration: item.RunTimeTicks / 10000,
|
||||
genres: item.GenreItems?.map((entry) => ({
|
||||
_itemType: LibraryItem.GENRE,
|
||||
_serverId: server?.id || '',
|
||||
_serverType: ServerType.JELLYFIN,
|
||||
id: entry.Id,
|
||||
imageUrl: null,
|
||||
itemType: LibraryItem.GENRE,
|
||||
name: entry.Name,
|
||||
})),
|
||||
id: item.Id,
|
||||
imagePlaceholderUrl,
|
||||
imageUrl: imageUrl || null,
|
||||
itemType: LibraryItem.PLAYLIST,
|
||||
name: item.Name,
|
||||
owner: null,
|
||||
ownerId: null,
|
||||
@@ -504,12 +512,12 @@ const normalizeGenre = (
|
||||
server: null | ServerListItem,
|
||||
): Genre => {
|
||||
return {
|
||||
_itemType: LibraryItem.GENRE,
|
||||
_serverId: server?.id || '',
|
||||
_serverType: ServerType.JELLYFIN,
|
||||
albumCount: undefined,
|
||||
id: item.Id,
|
||||
imageUrl: getGenreCoverArtUrl({ baseUrl: server?.url || '', item, size: 200 }),
|
||||
itemType: LibraryItem.GENRE,
|
||||
name: item.Name,
|
||||
songCount: undefined,
|
||||
};
|
||||
|
||||
@@ -151,6 +151,7 @@ const normalizeSong = (
|
||||
album: item.album,
|
||||
albumId: item.albumId,
|
||||
...getArtists(item),
|
||||
_itemType: LibraryItem.SONG,
|
||||
_serverId: server?.id || 'unknown',
|
||||
_serverType: ServerType.NAVIDROME,
|
||||
artistName: item.artist,
|
||||
@@ -176,15 +177,16 @@ const normalizeSong = (
|
||||
? { album: item.rgAlbumGain, track: item.rgTrackGain }
|
||||
: null,
|
||||
genres: (item.genres || []).map((genre) => ({
|
||||
_itemType: LibraryItem.GENRE,
|
||||
_serverId: server?.id || 'unknown',
|
||||
_serverType: ServerType.NAVIDROME,
|
||||
id: genre.id,
|
||||
imageUrl: null,
|
||||
itemType: LibraryItem.GENRE,
|
||||
name: genre.name,
|
||||
})),
|
||||
id,
|
||||
imagePlaceholderUrl,
|
||||
imageUrl,
|
||||
itemType: LibraryItem.SONG,
|
||||
lastPlayedAt: normalizePlayDate(item),
|
||||
lyrics: item.lyrics ? item.lyrics : null,
|
||||
mbzRecordingId: item.mbzReleaseTrackId || null,
|
||||
@@ -278,6 +280,7 @@ const normalizeAlbum = (
|
||||
return {
|
||||
...parseAlbumTags(item),
|
||||
...getArtists(item),
|
||||
_itemType: LibraryItem.ALBUM,
|
||||
_serverId: server?.id || 'unknown',
|
||||
_serverType: ServerType.NAVIDROME,
|
||||
albumArtist: item.albumArtist,
|
||||
@@ -292,17 +295,18 @@ const normalizeAlbum = (
|
||||
? ExplicitStatus.CLEAN
|
||||
: null,
|
||||
genres: (item.genres || []).map((genre) => ({
|
||||
_itemType: LibraryItem.GENRE,
|
||||
_serverId: server?.id || 'unknown',
|
||||
_serverType: ServerType.NAVIDROME,
|
||||
id: genre.id,
|
||||
imageUrl: null,
|
||||
itemType: LibraryItem.GENRE,
|
||||
name: genre.name,
|
||||
})),
|
||||
id: item.id,
|
||||
imagePlaceholderUrl,
|
||||
imageUrl,
|
||||
isCompilation: item.compilation,
|
||||
|
||||
itemType: LibraryItem.ALBUM,
|
||||
isCompilation: item.compilation,
|
||||
lastPlayedAt: normalizePlayDate(item),
|
||||
mbzId: item.mbzAlbumId || null,
|
||||
name: item.name,
|
||||
@@ -363,6 +367,7 @@ const normalizeAlbumArtist = (
|
||||
}
|
||||
|
||||
return {
|
||||
_itemType: LibraryItem.ALBUM_ARTIST,
|
||||
_serverId: server?.id || 'unknown',
|
||||
_serverType: ServerType.NAVIDROME,
|
||||
albumCount,
|
||||
@@ -370,14 +375,15 @@ const normalizeAlbumArtist = (
|
||||
biography: item.biography || null,
|
||||
duration: null,
|
||||
genres: (item.genres || []).map((genre) => ({
|
||||
_itemType: LibraryItem.GENRE,
|
||||
_serverId: server?.id || 'unknown',
|
||||
_serverType: ServerType.NAVIDROME,
|
||||
id: genre.id,
|
||||
imageUrl: null,
|
||||
itemType: LibraryItem.GENRE,
|
||||
name: genre.name,
|
||||
})),
|
||||
id: item.id,
|
||||
imageUrl: imageUrl || null,
|
||||
itemType: LibraryItem.ALBUM_ARTIST,
|
||||
lastPlayedAt: normalizePlayDate(item),
|
||||
mbz: item.mbzArtistId || null,
|
||||
name: item.name,
|
||||
@@ -410,6 +416,7 @@ const normalizePlaylist = (
|
||||
const imagePlaceholderUrl = null;
|
||||
|
||||
return {
|
||||
_itemType: LibraryItem.PLAYLIST,
|
||||
_serverId: server?.id || 'unknown',
|
||||
_serverType: ServerType.NAVIDROME,
|
||||
description: item.comment,
|
||||
@@ -418,7 +425,6 @@ const normalizePlaylist = (
|
||||
id: item.id,
|
||||
imagePlaceholderUrl,
|
||||
imageUrl,
|
||||
itemType: LibraryItem.PLAYLIST,
|
||||
name: item.name,
|
||||
owner: item.ownerName,
|
||||
ownerId: item.ownerId,
|
||||
@@ -435,12 +441,12 @@ const normalizeGenre = (
|
||||
server: null | ServerListItem,
|
||||
): Genre => {
|
||||
return {
|
||||
_itemType: LibraryItem.GENRE,
|
||||
_serverId: server?.id || 'unknown',
|
||||
_serverType: ServerType.NAVIDROME,
|
||||
albumCount: undefined,
|
||||
id: item.id,
|
||||
imageUrl: null,
|
||||
itemType: LibraryItem.GENRE,
|
||||
name: item.name,
|
||||
songCount: undefined,
|
||||
};
|
||||
|
||||
@@ -98,21 +98,21 @@ const getGenres = (
|
||||
): Genre[] => {
|
||||
return item.genres
|
||||
? item.genres.map((genre) => ({
|
||||
_itemType: LibraryItem.GENRE,
|
||||
_serverId: server?.id || 'unknown',
|
||||
_serverType: ServerType.SUBSONIC,
|
||||
id: genre.name,
|
||||
imageUrl: null,
|
||||
itemType: LibraryItem.GENRE,
|
||||
name: genre.name,
|
||||
}))
|
||||
: item.genre
|
||||
? [
|
||||
{
|
||||
_itemType: LibraryItem.GENRE,
|
||||
_serverId: server?.id || 'unknown',
|
||||
_serverType: ServerType.SUBSONIC,
|
||||
id: item.genre,
|
||||
imageUrl: null,
|
||||
itemType: LibraryItem.GENRE,
|
||||
name: item.genre,
|
||||
},
|
||||
]
|
||||
@@ -135,6 +135,7 @@ const normalizeSong = (
|
||||
const streamUrl = `${server?.url}/rest/stream.view?id=${item.id}&v=1.13.0&c=Feishin&${server?.credential}`;
|
||||
|
||||
return {
|
||||
_itemType: LibraryItem.SONG,
|
||||
_serverId: server?.id || 'unknown',
|
||||
_serverType: ServerType.SUBSONIC,
|
||||
album: item.album || '',
|
||||
@@ -170,7 +171,6 @@ const normalizeSong = (
|
||||
id: item.id.toString(),
|
||||
imagePlaceholderUrl: null,
|
||||
imageUrl,
|
||||
itemType: LibraryItem.SONG,
|
||||
lastPlayedAt: null,
|
||||
lyrics: null,
|
||||
mbzRecordingId: item.musicBrainzId || null,
|
||||
@@ -215,6 +215,7 @@ const normalizeAlbumArtist = (
|
||||
}) || null;
|
||||
|
||||
return {
|
||||
_itemType: LibraryItem.ALBUM_ARTIST,
|
||||
_serverId: server?.id || 'unknown',
|
||||
_serverType: ServerType.SUBSONIC,
|
||||
albumCount: item.albumCount ? Number(item.albumCount) : 0,
|
||||
@@ -224,7 +225,6 @@ const normalizeAlbumArtist = (
|
||||
genres: [],
|
||||
id: item.id.toString(),
|
||||
imageUrl,
|
||||
itemType: LibraryItem.ALBUM_ARTIST,
|
||||
lastPlayedAt: null,
|
||||
mbz: null,
|
||||
name: item.name,
|
||||
@@ -250,6 +250,7 @@ const normalizeAlbum = (
|
||||
}) || null;
|
||||
|
||||
return {
|
||||
_itemType: LibraryItem.ALBUM,
|
||||
_serverId: server?.id || 'unknown',
|
||||
_serverType: ServerType.SUBSONIC,
|
||||
albumArtist: item.artist,
|
||||
@@ -270,7 +271,6 @@ const normalizeAlbum = (
|
||||
imagePlaceholderUrl: null,
|
||||
imageUrl,
|
||||
isCompilation: null,
|
||||
itemType: LibraryItem.ALBUM,
|
||||
lastPlayedAt: null,
|
||||
mbzId: null,
|
||||
name: item.name,
|
||||
@@ -302,6 +302,7 @@ const normalizePlaylist = (
|
||||
server?: null | ServerListItemWithCredential,
|
||||
): Playlist => {
|
||||
return {
|
||||
_itemType: LibraryItem.PLAYLIST,
|
||||
_serverId: server?.id || 'unknown',
|
||||
_serverType: ServerType.SUBSONIC,
|
||||
description: item.comment || null,
|
||||
@@ -315,7 +316,6 @@ const normalizePlaylist = (
|
||||
credential: server?.credential,
|
||||
size: 300,
|
||||
}),
|
||||
itemType: LibraryItem.PLAYLIST,
|
||||
name: item.name,
|
||||
owner: item.owner,
|
||||
ownerId: item.owner,
|
||||
@@ -330,12 +330,12 @@ const normalizeGenre = (
|
||||
server: null | ServerListItemWithCredential,
|
||||
): Genre => {
|
||||
return {
|
||||
_itemType: LibraryItem.GENRE,
|
||||
_serverId: server?.id || 'unknown',
|
||||
_serverType: ServerType.SUBSONIC,
|
||||
albumCount: item.albumCount,
|
||||
id: item.value,
|
||||
imageUrl: null,
|
||||
itemType: LibraryItem.GENRE,
|
||||
name: item.value,
|
||||
songCount: item.songCount,
|
||||
};
|
||||
|
||||
@@ -164,6 +164,7 @@ export enum ImageType {
|
||||
}
|
||||
|
||||
export type Album = {
|
||||
_itemType: LibraryItem.ALBUM;
|
||||
_serverId: string;
|
||||
_serverType: ServerType;
|
||||
albumArtist: string;
|
||||
@@ -179,7 +180,6 @@ export type Album = {
|
||||
imagePlaceholderUrl: null | string;
|
||||
imageUrl: null | string;
|
||||
isCompilation: boolean | null;
|
||||
itemType: LibraryItem.ALBUM;
|
||||
lastPlayedAt: null | string;
|
||||
mbzId: null | string;
|
||||
name: string;
|
||||
@@ -201,6 +201,7 @@ export type Album = {
|
||||
} & { songs?: Song[] };
|
||||
|
||||
export type AlbumArtist = {
|
||||
_itemType: LibraryItem.ALBUM_ARTIST;
|
||||
_serverId: string;
|
||||
_serverType: ServerType;
|
||||
albumCount: null | number;
|
||||
@@ -210,7 +211,6 @@ export type AlbumArtist = {
|
||||
genres: Genre[];
|
||||
id: string;
|
||||
imageUrl: null | string;
|
||||
itemType: LibraryItem.ALBUM_ARTIST;
|
||||
lastPlayedAt: null | string;
|
||||
mbz: null | string;
|
||||
name: string;
|
||||
@@ -222,12 +222,12 @@ export type AlbumArtist = {
|
||||
};
|
||||
|
||||
export type Artist = {
|
||||
_itemType: LibraryItem.ARTIST;
|
||||
_serverId: string;
|
||||
_serverType: ServerType;
|
||||
biography: null | string;
|
||||
createdAt: string;
|
||||
id: string;
|
||||
itemType: LibraryItem.ARTIST;
|
||||
name: string;
|
||||
remoteCreatedAt: null | string;
|
||||
updatedAt: string;
|
||||
@@ -262,12 +262,12 @@ export type GainInfo = {
|
||||
};
|
||||
|
||||
export type Genre = {
|
||||
_itemType: LibraryItem.GENRE;
|
||||
_serverId: string;
|
||||
_serverType: ServerType;
|
||||
albumCount?: number;
|
||||
id: string;
|
||||
imageUrl: null | string;
|
||||
itemType: LibraryItem.GENRE;
|
||||
name: string;
|
||||
songCount?: number;
|
||||
};
|
||||
@@ -300,6 +300,7 @@ export type MusicFolder = {
|
||||
export type MusicFoldersResponse = MusicFolder[];
|
||||
|
||||
export type Playlist = {
|
||||
_itemType: LibraryItem.PLAYLIST;
|
||||
_serverId: string;
|
||||
_serverType: ServerType;
|
||||
description: null | string;
|
||||
@@ -308,7 +309,6 @@ export type Playlist = {
|
||||
id: string;
|
||||
imagePlaceholderUrl: null | string;
|
||||
imageUrl: null | string;
|
||||
itemType: LibraryItem.PLAYLIST;
|
||||
name: string;
|
||||
owner: null | string;
|
||||
ownerId: null | string;
|
||||
@@ -331,6 +331,7 @@ export type RelatedArtist = {
|
||||
};
|
||||
|
||||
export type Song = {
|
||||
_itemType: LibraryItem.SONG;
|
||||
_serverId: string;
|
||||
_serverType: ServerType;
|
||||
album: null | string;
|
||||
@@ -355,7 +356,6 @@ export type Song = {
|
||||
id: string;
|
||||
imagePlaceholderUrl: null | string;
|
||||
imageUrl: null | string;
|
||||
itemType: LibraryItem.SONG;
|
||||
lastPlayedAt: null | string;
|
||||
lyrics: null | string;
|
||||
mbzRecordingId: null | string;
|
||||
|
||||
Reference in New Issue
Block a user