mirror of
https://github.com/jeffvli/feishin.git
synced 2026-05-10 04:30:25 +02:00
Adjust album/song types
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
import { api } from '../lib';
|
import { api } from '../lib';
|
||||||
import { AlbumsResponse, BasePaginationRequest } from './types';
|
import { AlbumResponse, AlbumsResponse, BasePaginationRequest } from './types';
|
||||||
|
|
||||||
export interface AlbumsRequest extends BasePaginationRequest {
|
export interface AlbumsRequest extends BasePaginationRequest {
|
||||||
orderBy: string;
|
orderBy: string;
|
||||||
@@ -8,7 +8,7 @@ export interface AlbumsRequest extends BasePaginationRequest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const getAlbum = async (params: { id: number }, signal?: AbortSignal) => {
|
const getAlbum = async (params: { id: number }, signal?: AbortSignal) => {
|
||||||
const { data } = await api.get<AlbumsResponse>(`/albums/${params.id}`, {
|
const { data } = await api.get<AlbumResponse>(`/albums/${params.id}`, {
|
||||||
signal,
|
signal,
|
||||||
});
|
});
|
||||||
return data;
|
return data;
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
import { Album } from '../../types';
|
||||||
|
|
||||||
export interface BaseResponse<T> {
|
export interface BaseResponse<T> {
|
||||||
data: T;
|
data: T;
|
||||||
error?: string | any;
|
error?: string | any;
|
||||||
@@ -112,45 +114,6 @@ export type AlbumResponse = BaseResponse<Album>;
|
|||||||
|
|
||||||
export type AlbumsResponse = BasePaginatedResponse<Album[]>;
|
export type AlbumsResponse = BasePaginatedResponse<Album[]>;
|
||||||
|
|
||||||
export interface Album {
|
|
||||||
_count: Count;
|
|
||||||
albumArtistId: number;
|
|
||||||
createdAt: string;
|
|
||||||
date: string;
|
|
||||||
genres: GenreResponse[];
|
|
||||||
id: number;
|
|
||||||
name: string;
|
|
||||||
remoteCreatedAt: string;
|
|
||||||
remoteId: string;
|
|
||||||
serverFolderId: number;
|
|
||||||
songs: Song[];
|
|
||||||
updatedAt: string;
|
|
||||||
year: number;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface Song {
|
|
||||||
album?: Partial<Album>;
|
|
||||||
albumId: number;
|
|
||||||
artistName: null;
|
|
||||||
artists?: ArtistResponse[];
|
|
||||||
bitRate: number;
|
|
||||||
container: string;
|
|
||||||
createdAt: string;
|
|
||||||
date: string;
|
|
||||||
disc: number;
|
|
||||||
duration: number;
|
|
||||||
externals?: ExternalResponse[];
|
|
||||||
id: number;
|
|
||||||
images?: ImageResponse[];
|
|
||||||
name: string;
|
|
||||||
remoteCreatedAt: string;
|
|
||||||
remoteId: string;
|
|
||||||
serverFolderId: number;
|
|
||||||
track: number;
|
|
||||||
updatedAt: string;
|
|
||||||
year: number;
|
|
||||||
}
|
|
||||||
|
|
||||||
export type Count = {
|
export type Count = {
|
||||||
artists?: number;
|
artists?: number;
|
||||||
externals?: number;
|
externals?: number;
|
||||||
|
|||||||
@@ -27,14 +27,14 @@ const MetadataStack = styled.div`
|
|||||||
|
|
||||||
export const LeftControls = () => {
|
export const LeftControls = () => {
|
||||||
const song = usePlayerStore((state) => state.current.song);
|
const song = usePlayerStore((state) => state.current.song);
|
||||||
const title = song?.title;
|
const title = song?.name;
|
||||||
const artists = song?.artist?.map((artist) => artist?.title).join(', ');
|
const artists = song?.artists?.map((artist) => artist?.name).join(', ');
|
||||||
const album = song?.album;
|
const album = song?.album;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<LeftControlsContainer>
|
<LeftControlsContainer>
|
||||||
<ImageWrapper>
|
<ImageWrapper>
|
||||||
<img alt="img" height={60} src={song?.image} width={60} />
|
<img alt="img" height={60} src={song?.imageUrl} width={60} />
|
||||||
</ImageWrapper>
|
</ImageWrapper>
|
||||||
<MetadataStack>
|
<MetadataStack>
|
||||||
<Text
|
<Text
|
||||||
|
|||||||
@@ -56,25 +56,12 @@ export const usePlayQueueHandler = () => {
|
|||||||
: getSubsonicStreamUrl(auth, song, deviceId);
|
: getSubsonicStreamUrl(auth, song, deviceId);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
albumId: song.albumId,
|
...song,
|
||||||
artistName: song.artistName,
|
|
||||||
duration: song.duration,
|
|
||||||
id: song.id,
|
|
||||||
streamUrl,
|
streamUrl,
|
||||||
title: song.name,
|
|
||||||
year: song.year,
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return song;
|
||||||
albumId: song.albumId,
|
|
||||||
artistName: song.artistName,
|
|
||||||
duration: song.duration,
|
|
||||||
id: song.id,
|
|
||||||
streamUrl: song.streamUrl,
|
|
||||||
title: song.name,
|
|
||||||
year: song.year,
|
|
||||||
};
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const playerData = addToQueue(songs, options.play);
|
const playerData = addToQueue(songs, options.play);
|
||||||
|
|||||||
@@ -111,6 +111,8 @@ const songs = (
|
|||||||
items: any[],
|
items: any[],
|
||||||
options: {
|
options: {
|
||||||
deviceId: string;
|
deviceId: string;
|
||||||
|
imageUrl?: string;
|
||||||
|
serverFolderId?: number;
|
||||||
serverType?: string;
|
serverType?: string;
|
||||||
token: string;
|
token: string;
|
||||||
url?: string;
|
url?: string;
|
||||||
@@ -126,6 +128,7 @@ const songs = (
|
|||||||
const url = options.url ? options.url : item.server.serverUrls[0];
|
const url = options.url ? options.url : item.server.serverUrls[0];
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
album: item.album.name,
|
||||||
albumId: item.albumId,
|
albumId: item.albumId,
|
||||||
artistName: item.artistName,
|
artistName: item.artistName,
|
||||||
artists: relatedArtists(item.artists),
|
artists: relatedArtists(item.artists),
|
||||||
@@ -138,10 +141,13 @@ const songs = (
|
|||||||
duration: item.duration,
|
duration: item.duration,
|
||||||
genres: relatedGenres(item.genres),
|
genres: relatedGenres(item.genres),
|
||||||
id: item.id,
|
id: item.id,
|
||||||
image: primaryImage(item.images, serverType, url, item.remoteId),
|
imageUrl:
|
||||||
|
primaryImage(item.images, serverType, url, item.remoteId) ||
|
||||||
|
options.imageUrl,
|
||||||
name: item.name,
|
name: item.name,
|
||||||
remoteCreatedAt: item.remoteCreatedAt,
|
remoteCreatedAt: item.remoteCreatedAt,
|
||||||
remoteId: item.remoteId,
|
remoteId: item.remoteId,
|
||||||
|
serverFolderId: item.serverFolderId,
|
||||||
serverId: item.serverId,
|
serverId: item.serverId,
|
||||||
streamUrl: streamUrl(serverType, {
|
streamUrl: streamUrl(serverType, {
|
||||||
deviceId: options.deviceId,
|
deviceId: options.deviceId,
|
||||||
@@ -167,16 +173,23 @@ const albums = (items: any[], user: User) => {
|
|||||||
(r: Rating) => r.userId === user.id
|
(r: Rating) => r.userId === user.id
|
||||||
)?.value;
|
)?.value;
|
||||||
const averageRating = meanBy(item.ratings, 'value');
|
const averageRating = meanBy(item.ratings, 'value');
|
||||||
|
const imageUrl = primaryImage(
|
||||||
|
item.images,
|
||||||
|
serverType,
|
||||||
|
url,
|
||||||
|
item.remoteId
|
||||||
|
);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
albumArtist: item.albumArtist,
|
||||||
albumArtistId: item.albumArtistId,
|
albumArtistId: item.albumArtistId,
|
||||||
averageRating,
|
averageRating,
|
||||||
createdAt: item.createdAt,
|
createdAt: item.createdAt,
|
||||||
dateCreated: item.date,
|
date: item.date,
|
||||||
deleted: item.deleted,
|
deleted: item.deleted,
|
||||||
genres: relatedGenres(item.genres),
|
genres: relatedGenres(item.genres),
|
||||||
id: item.id,
|
id: item.id,
|
||||||
image: primaryImage(item.images, serverType, url, item.remoteId),
|
imageUrl,
|
||||||
name: item.name,
|
name: item.name,
|
||||||
rating,
|
rating,
|
||||||
remoteCreatedAt: item.remoteCreatedAt,
|
remoteCreatedAt: item.remoteCreatedAt,
|
||||||
@@ -186,6 +199,8 @@ const albums = (items: any[], user: User) => {
|
|||||||
songCount: item._count.songs,
|
songCount: item._count.songs,
|
||||||
songs: songs(item.songs, {
|
songs: songs(item.songs, {
|
||||||
deviceId: user.deviceId,
|
deviceId: user.deviceId,
|
||||||
|
imageUrl,
|
||||||
|
serverFolderId: item.serverFolderId,
|
||||||
serverType,
|
serverType,
|
||||||
token,
|
token,
|
||||||
url,
|
url,
|
||||||
|
|||||||
+66
-86
@@ -103,46 +103,55 @@ export interface GenericItem {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface APIResult {
|
export interface APIResult {
|
||||||
data: Album[] | Artist[] | Genre[] | Playlist[] | Song[];
|
data: Album[] | Artist[] | Genre[] | Song[];
|
||||||
totalRecordCount?: number;
|
totalRecordCount?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Album {
|
export interface Album {
|
||||||
albumArtist?: string;
|
albumArtist: Partial<AlbumArtist>;
|
||||||
albumArtistId: string;
|
albumArtistId: string;
|
||||||
albumGenre?: string;
|
averageRating: number;
|
||||||
albumId: string;
|
container: string;
|
||||||
artist?: Artist[];
|
createdAt: string;
|
||||||
created: string;
|
date: string;
|
||||||
duration: number;
|
deleted: boolean;
|
||||||
genre?: Genre[];
|
genres: Genre[];
|
||||||
id: string;
|
id: number;
|
||||||
image: string;
|
imageUrl: string;
|
||||||
isDir?: boolean;
|
name: string;
|
||||||
playCount?: number;
|
rating: number;
|
||||||
song?: Song[];
|
remoteCreatedAt: string;
|
||||||
|
remoteId: string;
|
||||||
|
serverFolderId: number;
|
||||||
|
serverType: ServerType | string;
|
||||||
songCount: number;
|
songCount: number;
|
||||||
starred?: string;
|
songs: Song[];
|
||||||
title: string;
|
updatedAt: string;
|
||||||
type: Item.ALBUM;
|
year: number;
|
||||||
uniqueId: string;
|
}
|
||||||
userRating?: number;
|
|
||||||
year?: number;
|
export interface AlbumArtist {
|
||||||
|
biography?: string;
|
||||||
|
createdAt: string;
|
||||||
|
deleted: boolean;
|
||||||
|
id: number;
|
||||||
|
name: string;
|
||||||
|
remoteCreatedAt: string;
|
||||||
|
remoteId: string;
|
||||||
|
serverId: number;
|
||||||
|
updatedAt: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Artist {
|
export interface Artist {
|
||||||
album?: Album[];
|
biography?: string;
|
||||||
albumCount?: number;
|
createdAt: string;
|
||||||
duration?: number;
|
deleted: boolean;
|
||||||
genre?: Genre[];
|
id: number;
|
||||||
id?: string;
|
name: string;
|
||||||
image?: string;
|
remoteCreatedAt: string;
|
||||||
info?: ArtistInfo;
|
remoteId: string;
|
||||||
starred?: string;
|
serverId: number;
|
||||||
title: string;
|
updatedAt: string;
|
||||||
type?: Item.ARTIST;
|
|
||||||
uniqueId?: string;
|
|
||||||
userRating?: number;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ArtistInfo {
|
export interface ArtistInfo {
|
||||||
@@ -152,72 +161,39 @@ export interface ArtistInfo {
|
|||||||
similarArtist?: Artist[];
|
similarArtist?: Artist[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Folder {
|
|
||||||
created: string;
|
|
||||||
id: string;
|
|
||||||
image: string;
|
|
||||||
isDir?: boolean;
|
|
||||||
title: string;
|
|
||||||
type: Item.FOLDER;
|
|
||||||
uniqueId: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface Genre {
|
export interface Genre {
|
||||||
albumCount?: number;
|
albumCount?: number;
|
||||||
id: string;
|
id: string;
|
||||||
|
name: string;
|
||||||
songCount?: number;
|
songCount?: number;
|
||||||
title: string;
|
|
||||||
type?: Item.GENRE;
|
type?: Item.GENRE;
|
||||||
uniqueId?: string;
|
uniqueId?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Playlist {
|
|
||||||
changed?: string;
|
|
||||||
comment?: string;
|
|
||||||
created?: string;
|
|
||||||
duration: number;
|
|
||||||
genre?: Genre[];
|
|
||||||
id: string;
|
|
||||||
image: string;
|
|
||||||
owner?: string;
|
|
||||||
public?: boolean;
|
|
||||||
song?: Song[];
|
|
||||||
songCount?: number;
|
|
||||||
title: string;
|
|
||||||
type: Item.PLAYLIST;
|
|
||||||
uniqueId: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface Song {
|
export interface Song {
|
||||||
album?: string;
|
album: string;
|
||||||
albumArtist?: string;
|
albumId: number;
|
||||||
albumArtistId?: number;
|
artistName: null;
|
||||||
albumGenre?: string;
|
artists: Partial<Artist>[];
|
||||||
albumId?: number;
|
bitRate: number;
|
||||||
artist?: Artist[];
|
container: string;
|
||||||
artistName?: string | null;
|
createdAt: string;
|
||||||
bitRate?: number;
|
date: string;
|
||||||
contentType?: string;
|
deleted: boolean;
|
||||||
created?: string;
|
disc: number;
|
||||||
discNumber?: number;
|
duration: number;
|
||||||
duration?: number;
|
genres: Partial<Genre>[];
|
||||||
genre?: Genre[];
|
|
||||||
id: number;
|
id: number;
|
||||||
image?: string;
|
imageUrl: string;
|
||||||
isDir?: boolean;
|
name: string;
|
||||||
parent?: string;
|
remoteCreatedAt: string;
|
||||||
path?: string;
|
remoteId: string;
|
||||||
playCount?: number;
|
serverFolderId: number;
|
||||||
size?: number;
|
serverId: number;
|
||||||
starred?: string;
|
|
||||||
streamUrl: string;
|
streamUrl: string;
|
||||||
suffix?: string;
|
track: number;
|
||||||
title: string;
|
updatedAt: string;
|
||||||
track?: number;
|
year: number;
|
||||||
type?: Item.SONG;
|
|
||||||
uniqueId?: string;
|
|
||||||
userRating?: number;
|
|
||||||
year?: number;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ScanStatus {
|
export interface ScanStatus {
|
||||||
@@ -247,3 +223,7 @@ export interface ServerFolderAuth {
|
|||||||
userId: string;
|
userId: string;
|
||||||
username: string;
|
username: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface UniqueId {
|
||||||
|
uniqueId: string;
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user