mirror of
https://github.com/jeffvli/feishin.git
synced 2026-05-14 12:30:06 +02:00
rename internal types in domain models
This commit is contained in:
@@ -290,7 +290,7 @@ export const AlbumDetailContent = ({ background, tableRef }: AlbumDetailContentP
|
||||
|
||||
if (detailQuery.data.userFavorite) {
|
||||
deleteFavoriteMutation.mutate({
|
||||
apiClientProps: { serverId: detailQuery.data.serverId },
|
||||
apiClientProps: { serverId: detailQuery.data._serverId },
|
||||
query: {
|
||||
id: [detailQuery.data.id],
|
||||
type: LibraryItem.ALBUM,
|
||||
@@ -298,7 +298,7 @@ export const AlbumDetailContent = ({ background, tableRef }: AlbumDetailContentP
|
||||
});
|
||||
} else {
|
||||
createFavoriteMutation.mutate({
|
||||
apiClientProps: { serverId: detailQuery.data.serverId },
|
||||
apiClientProps: { serverId: detailQuery.data._serverId },
|
||||
query: {
|
||||
id: [detailQuery.data.id],
|
||||
type: LibraryItem.ALBUM,
|
||||
|
||||
@@ -41,8 +41,8 @@ export const AlbumDetailHeader = forwardRef(
|
||||
const { t } = useTranslation();
|
||||
|
||||
const showRating =
|
||||
detailQuery?.data?.serverType === ServerType.NAVIDROME ||
|
||||
detailQuery?.data?.serverType === ServerType.SUBSONIC;
|
||||
detailQuery?.data?._serverType === ServerType.NAVIDROME ||
|
||||
detailQuery?.data?._serverType === ServerType.SUBSONIC;
|
||||
|
||||
const originalDifferentFromRelease =
|
||||
detailQuery.data?.originalDate &&
|
||||
@@ -137,7 +137,7 @@ export const AlbumDetailHeader = forwardRef(
|
||||
if (!detailQuery?.data) return;
|
||||
|
||||
updateRatingMutation.mutate({
|
||||
apiClientProps: { serverId: detailQuery.data.serverId },
|
||||
apiClientProps: { serverId: detailQuery.data._serverId },
|
||||
query: {
|
||||
item: [detailQuery.data],
|
||||
rating,
|
||||
|
||||
@@ -69,7 +69,7 @@ const DummyAlbumDetailRoute = () => {
|
||||
try {
|
||||
if (wasFavorite) {
|
||||
await deleteFavoriteMutation.mutateAsync({
|
||||
apiClientProps: { serverId: detailQuery.data.serverId },
|
||||
apiClientProps: { serverId: detailQuery.data._serverId },
|
||||
query: {
|
||||
id: [detailQuery.data.id],
|
||||
type: LibraryItem.SONG,
|
||||
@@ -77,7 +77,7 @@ const DummyAlbumDetailRoute = () => {
|
||||
});
|
||||
} else {
|
||||
await createFavoriteMutation.mutateAsync({
|
||||
apiClientProps: { serverId: detailQuery.data.serverId },
|
||||
apiClientProps: { serverId: detailQuery.data._serverId },
|
||||
query: {
|
||||
id: [detailQuery.data.id],
|
||||
type: LibraryItem.SONG,
|
||||
|
||||
@@ -79,7 +79,7 @@ export const AlbumArtistDetailHeader = forwardRef(
|
||||
});
|
||||
};
|
||||
|
||||
const showRating = detailQuery?.data?.serverType === ServerType.NAVIDROME;
|
||||
const showRating = detailQuery?.data?._serverType === ServerType.NAVIDROME;
|
||||
|
||||
return (
|
||||
<LibraryHeader
|
||||
|
||||
@@ -41,7 +41,7 @@ export const useDiscordRpc = () => {
|
||||
|
||||
// Handle change detection
|
||||
const song = current[0];
|
||||
const trackChanged = lastUniqueId !== song.uniqueId;
|
||||
const trackChanged = lastUniqueId !== song._uniqueId;
|
||||
|
||||
/*
|
||||
1. If the song has just started, update status
|
||||
@@ -56,7 +56,7 @@ export const useDiscordRpc = () => {
|
||||
current[2] !== previous[2]
|
||||
) {
|
||||
if (trackChanged) {
|
||||
setlastUniqueId(song.uniqueId);
|
||||
setlastUniqueId(song._uniqueId);
|
||||
}
|
||||
|
||||
const start = Math.round(Date.now() - current[1] * 1000);
|
||||
@@ -126,12 +126,12 @@ export const useDiscordRpc = () => {
|
||||
}
|
||||
|
||||
if (discordSettings.showServerImage && song) {
|
||||
if (song.serverType === ServerType.JELLYFIN && song.imageUrl) {
|
||||
if (song._serverType === ServerType.JELLYFIN && song.imageUrl) {
|
||||
activity.largeImageKey = song.imageUrl;
|
||||
} else if (song.serverType === ServerType.NAVIDROME) {
|
||||
} else if (song._serverType === ServerType.NAVIDROME) {
|
||||
try {
|
||||
const info = await controller.getAlbumInfo({
|
||||
apiClientProps: { serverId: song.serverId },
|
||||
apiClientProps: { serverId: song._serverId },
|
||||
query: { id: song.albumId },
|
||||
});
|
||||
|
||||
|
||||
@@ -99,7 +99,7 @@ export const lyricsQueries = {
|
||||
return queryOptions({
|
||||
gcTime: Infinity,
|
||||
queryFn: async ({ signal }): Promise<FullLyricsMetadata | null | StructuredLyric[]> => {
|
||||
const server = getServerById(song?.serverId);
|
||||
const server = getServerById(song?._serverId);
|
||||
if (!server) throw new Error('Server not found');
|
||||
if (!song) return null;
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ export const Lyrics = () => {
|
||||
lyricsQueries.songLyrics(
|
||||
{
|
||||
query: { songId: currentSong?.id || '' },
|
||||
serverId: currentSong?.serverId || '',
|
||||
serverId: currentSong?._serverId || '',
|
||||
},
|
||||
currentSong,
|
||||
),
|
||||
@@ -73,13 +73,13 @@ export const Lyrics = () => {
|
||||
const handleOnResetLyric = useCallback(() => {
|
||||
queryClient.invalidateQueries({
|
||||
exact: true,
|
||||
queryKey: queryKeys.songs.lyrics(currentSong?.serverId, { songId: currentSong?.id }),
|
||||
queryKey: queryKeys.songs.lyrics(currentSong?._serverId, { songId: currentSong?.id }),
|
||||
});
|
||||
}, [currentSong?.id, currentSong?.serverId]);
|
||||
}, [currentSong?.id, currentSong?._serverId]);
|
||||
|
||||
const handleOnRemoveLyric = useCallback(() => {
|
||||
queryClient.setQueryData(
|
||||
queryKeys.songs.lyrics(currentSong?.serverId, { songId: currentSong?.id }),
|
||||
queryKeys.songs.lyrics(currentSong?._serverId, { songId: currentSong?.id }),
|
||||
(prev: FullLyricsMetadata | undefined) => {
|
||||
if (!prev) {
|
||||
return undefined;
|
||||
@@ -91,7 +91,7 @@ export const Lyrics = () => {
|
||||
};
|
||||
},
|
||||
);
|
||||
}, [currentSong?.id, currentSong?.serverId]);
|
||||
}, [currentSong?.id, currentSong?._serverId]);
|
||||
|
||||
const fetchTranslation = useCallback(async () => {
|
||||
if (!lyrics) return;
|
||||
@@ -126,7 +126,7 @@ export const Lyrics = () => {
|
||||
remoteSource: override?.source as LyricSource | undefined,
|
||||
song: currentSong,
|
||||
},
|
||||
serverId: currentSong?.serverId || '',
|
||||
serverId: currentSong?._serverId || '',
|
||||
}),
|
||||
);
|
||||
|
||||
|
||||
@@ -122,7 +122,7 @@ export const PlayQueue = forwardRef(({ searchTerm, type }: QueueProps, ref: Ref<
|
||||
const handleDragEnd = (e: RowDragEvent<QueueSong>) => {
|
||||
if (!e.nodes.length) return;
|
||||
const selectedUniqueIds = e.nodes
|
||||
.map((node) => node.data?.uniqueId)
|
||||
.map((node) => node.data?._uniqueId)
|
||||
.filter((e) => e !== undefined);
|
||||
|
||||
// const playerData = reorderQueue(selectedUniqueIds as string[], e.overNode?.data?.uniqueId);
|
||||
@@ -143,8 +143,8 @@ export const PlayQueue = forwardRef(({ searchTerm, type }: QueueProps, ref: Ref<
|
||||
const handleGridReady = () => {
|
||||
const { api } = tableRef?.current || {};
|
||||
|
||||
if (currentSong?.uniqueId) {
|
||||
const currentNode = api?.getRowNode(currentSong?.uniqueId);
|
||||
if (currentSong?._uniqueId) {
|
||||
const currentNode = api?.getRowNode(currentSong?._uniqueId);
|
||||
|
||||
if (!currentNode) return;
|
||||
api?.ensureNodeVisible(currentNode, 'middle');
|
||||
@@ -196,10 +196,10 @@ export const PlayQueue = forwardRef(({ searchTerm, type }: QueueProps, ref: Ref<
|
||||
const rowClassRules = useMemo<RowClassRules | undefined>(() => {
|
||||
return {
|
||||
'current-song': (params) => {
|
||||
return params.data.uniqueId === currentSong?.uniqueId;
|
||||
return params.data.uniqueId === currentSong?._uniqueId;
|
||||
},
|
||||
};
|
||||
}, [currentSong?.uniqueId]);
|
||||
}, [currentSong?._uniqueId]);
|
||||
|
||||
const previousSongRef = useRef<QueueSong | undefined>(undefined);
|
||||
|
||||
@@ -217,11 +217,11 @@ export const PlayQueue = forwardRef(({ searchTerm, type }: QueueProps, ref: Ref<
|
||||
return;
|
||||
}
|
||||
|
||||
const currentNode = currentSong?.uniqueId
|
||||
? api.getRowNode(currentSong.uniqueId)
|
||||
const currentNode = currentSong?._uniqueId
|
||||
? api.getRowNode(currentSong._uniqueId)
|
||||
: undefined;
|
||||
const previousNode = previousSongRef.current?.uniqueId
|
||||
? api.getRowNode(previousSongRef.current?.uniqueId)
|
||||
const previousNode = previousSongRef.current?._uniqueId
|
||||
? api.getRowNode(previousSongRef.current?._uniqueId)
|
||||
: undefined;
|
||||
|
||||
const rowNodes = [currentNode, previousNode].filter(
|
||||
@@ -248,8 +248,8 @@ export const PlayQueue = forwardRef(({ searchTerm, type }: QueueProps, ref: Ref<
|
||||
return;
|
||||
}
|
||||
|
||||
const currentNode = currentSong?.uniqueId
|
||||
? api.getRowNode(currentSong.uniqueId)
|
||||
const currentNode = currentSong?._uniqueId
|
||||
? api.getRowNode(currentSong._uniqueId)
|
||||
: undefined;
|
||||
|
||||
if (currentNode) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { Song } from '/@/shared/types/domain-types';
|
||||
import type { QueueSong, Song } from '/@/shared/types/domain-types';
|
||||
import type { CrossfadeStyle } from '/@/shared/types/types';
|
||||
import type { ReactPlayerProps } from 'react-player';
|
||||
|
||||
@@ -18,7 +18,7 @@ import { api } from '/@/renderer/api';
|
||||
import {
|
||||
crossfadeHandler,
|
||||
gaplessHandler,
|
||||
} from '/@/renderer/components/audio-player/utils/list-handlers';
|
||||
} from '/@/renderer/features/player/audio-player/utils/list-handlers';
|
||||
import { useWebAudio } from '/@/renderer/features/player/hooks/use-webaudio';
|
||||
import {
|
||||
TranscodingConfig,
|
||||
@@ -62,26 +62,30 @@ const getDuration = (ref: any) => {
|
||||
const EMPTY_SOURCE =
|
||||
'data:audio/mp3;base64,SUQzBAAAAAAAI1RTU0UAAAAPAAADTGF2ZjU2LjM2LjEwMAAAAAAAAAAAAAAA//OEAAAAAAAAAAAAAAAAAAAAAAAASW5mbwAAAA8AAAAEAAABIADAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDV1dXV1dXV1dXV1dXV1dXV1dXV1dXV1dXV6urq6urq6urq6urq6urq6urq6urq6urq6v////////////////////////////////8AAAAATGF2YzU2LjQxAAAAAAAAAAAAAAAAJAAAAAAAAAAAASDs90hvAAAAAAAAAAAAAAAAAAAA//MUZAAAAAGkAAAAAAAAA0gAAAAATEFN//MUZAMAAAGkAAAAAAAAA0gAAAAARTMu//MUZAYAAAGkAAAAAAAAA0gAAAAAOTku//MUZAkAAAGkAAAAAAAAA0gAAAAANVVV';
|
||||
|
||||
const useSongUrl = (transcode: TranscodingConfig, current: boolean, song?: Song): null | string => {
|
||||
const useSongUrl = (
|
||||
transcode: TranscodingConfig,
|
||||
current: boolean,
|
||||
song?: QueueSong,
|
||||
): null | string => {
|
||||
const prior = useRef(['', '']);
|
||||
|
||||
return useMemo(() => {
|
||||
if (song?.serverId) {
|
||||
if (song?._serverId) {
|
||||
// If we are the current track, we do not want a transcoding
|
||||
// reconfiguration to force a restart.
|
||||
if (current && prior.current[0] === song.uniqueId) {
|
||||
if (current && prior.current[0] === song._uniqueId) {
|
||||
return prior.current[1];
|
||||
}
|
||||
|
||||
if (!transcode.enabled) {
|
||||
// transcoding disabled; save the result
|
||||
prior.current = [song.uniqueId, song.streamUrl];
|
||||
prior.current = [song._uniqueId, song.streamUrl];
|
||||
return song.streamUrl;
|
||||
}
|
||||
|
||||
const result = api.controller.getTranscodingUrl({
|
||||
apiClientProps: {
|
||||
serverId: song.serverId,
|
||||
serverId: song._serverId,
|
||||
},
|
||||
query: {
|
||||
base: song.streamUrl,
|
||||
@@ -90,14 +94,14 @@ const useSongUrl = (transcode: TranscodingConfig, current: boolean, song?: Song)
|
||||
})!;
|
||||
|
||||
// transcoding enabled; save the updated result
|
||||
prior.current = [song.uniqueId, result];
|
||||
prior.current = [song._uniqueId, result];
|
||||
return result;
|
||||
}
|
||||
|
||||
// no track; clear result
|
||||
prior.current = ['', ''];
|
||||
return null;
|
||||
}, [current, song?.uniqueId, song?.serverId, song?.streamUrl, transcode]);
|
||||
}, [current, song?._uniqueId, song?._serverId, song?.streamUrl, transcode]);
|
||||
};
|
||||
|
||||
export interface AudioPlayerRef {
|
||||
|
||||
@@ -71,7 +71,7 @@ export const RightControls = () => {
|
||||
if (!song?.id) return;
|
||||
|
||||
addToFavoritesMutation.mutate({
|
||||
apiClientProps: { serverId: song?.serverId || '' },
|
||||
apiClientProps: { serverId: song?._serverId || '' },
|
||||
query: {
|
||||
id: [song.id],
|
||||
type: LibraryItem.SONG,
|
||||
@@ -83,7 +83,7 @@ export const RightControls = () => {
|
||||
if (!currentSong) return;
|
||||
|
||||
updateRatingMutation.mutate({
|
||||
apiClientProps: { serverId: currentSong?.serverId || '' },
|
||||
apiClientProps: { serverId: currentSong?._serverId || '' },
|
||||
query: {
|
||||
item: [currentSong],
|
||||
rating,
|
||||
@@ -95,7 +95,7 @@ export const RightControls = () => {
|
||||
if (!song?.id) return;
|
||||
|
||||
removeFromFavoritesMutation.mutate({
|
||||
apiClientProps: { serverId: song?.serverId || '' },
|
||||
apiClientProps: { serverId: song?._serverId || '' },
|
||||
query: {
|
||||
id: [song.id],
|
||||
type: LibraryItem.SONG,
|
||||
@@ -188,7 +188,7 @@ export const RightControls = () => {
|
||||
{
|
||||
id,
|
||||
itemType: LibraryItem.SONG,
|
||||
serverId,
|
||||
_serverId,
|
||||
} as Song, // This is not a type-safe cast, but it works because those are all the prop
|
||||
],
|
||||
rating,
|
||||
|
||||
@@ -103,7 +103,7 @@ export const useScrobble = () => {
|
||||
// Only trigger if the song changed, or the player changed. This should be the case
|
||||
// anyways, but who knows
|
||||
if (
|
||||
currentSong.uniqueId !== previous[0]?.uniqueId ||
|
||||
currentSong._uniqueId !== previous[0]?._uniqueId ||
|
||||
current[2] !== previous[2]
|
||||
) {
|
||||
const artists =
|
||||
@@ -141,15 +141,15 @@ export const useScrobble = () => {
|
||||
|
||||
if (
|
||||
(!isCurrentSongScrobbled && shouldSubmitScrobble) ||
|
||||
previousSong?.serverType === ServerType.JELLYFIN
|
||||
previousSong?._serverType === ServerType.JELLYFIN
|
||||
) {
|
||||
const position =
|
||||
previousSong?.serverType === ServerType.JELLYFIN
|
||||
previousSong?._serverType === ServerType.JELLYFIN
|
||||
? previousSongTimeSec * 1e7
|
||||
: undefined;
|
||||
|
||||
sendScrobble.mutate({
|
||||
apiClientProps: { serverId: previousSong?.serverId || '' },
|
||||
apiClientProps: { serverId: previousSong?._serverId || '' },
|
||||
query: {
|
||||
id: previousSong.id,
|
||||
position,
|
||||
@@ -173,7 +173,7 @@ export const useScrobble = () => {
|
||||
// Send start scrobble when song changes and the new song is playing
|
||||
if (currentStatus === PlayerStatus.PLAYING && currentSong?.id) {
|
||||
sendScrobble.mutate({
|
||||
apiClientProps: { serverId: currentSong?.serverId || '' },
|
||||
apiClientProps: { serverId: currentSong?._serverId || '' },
|
||||
query: {
|
||||
event: 'start',
|
||||
id: currentSong.id,
|
||||
@@ -182,7 +182,7 @@ export const useScrobble = () => {
|
||||
},
|
||||
});
|
||||
|
||||
if (currentSong?.serverType === ServerType.JELLYFIN) {
|
||||
if (currentSong?._serverType === ServerType.JELLYFIN) {
|
||||
// It is possible that another function sets an interval.
|
||||
// We only want one running, so clear the existing interval
|
||||
if (progressIntervalId.current) {
|
||||
@@ -379,7 +379,7 @@ export const useScrobble = () => {
|
||||
// multiple times in a row and playback goes normally (no next/previous)
|
||||
equalityFn: (a, b) =>
|
||||
// compute whether the song changed
|
||||
a[0]?.uniqueId === b[0]?.uniqueId &&
|
||||
a[0]?._uniqueId === b[0]?._uniqueId &&
|
||||
// compute whether the same player: relevant for repeat one and repeat all (one track)
|
||||
a[2] === b[2],
|
||||
},
|
||||
|
||||
+1
-1
@@ -377,7 +377,7 @@ export const PlaylistDetailSongListHeaderFilters = ({
|
||||
if (!detailQuery.data) return;
|
||||
deletePlaylistMutation?.mutate(
|
||||
{
|
||||
apiClientProps: { serverId: detailQuery.data.serverId },
|
||||
apiClientProps: { serverId: detailQuery.data._serverId },
|
||||
query: { id: detailQuery.data.id },
|
||||
},
|
||||
{
|
||||
|
||||
@@ -56,7 +56,7 @@ const PlaylistDetailSongListRoute = () => {
|
||||
|
||||
createPlaylistMutation.mutate(
|
||||
{
|
||||
apiClientProps: { serverId: detailQuery?.data?.serverId },
|
||||
apiClientProps: { serverId: detailQuery?.data?._serverId },
|
||||
body: {
|
||||
_custom: {
|
||||
navidrome: {
|
||||
@@ -83,7 +83,7 @@ const PlaylistDetailSongListRoute = () => {
|
||||
},
|
||||
);
|
||||
deletePlaylistMutation.mutate({
|
||||
apiClientProps: { serverId: detailQuery?.data?.serverId },
|
||||
apiClientProps: { serverId: detailQuery?.data?._serverId },
|
||||
query: { id: playlistId },
|
||||
});
|
||||
},
|
||||
@@ -124,7 +124,7 @@ const PlaylistDetailSongListRoute = () => {
|
||||
}),
|
||||
)
|
||||
}
|
||||
serverId={detailQuery?.data?.serverId || ''}
|
||||
serverId={detailQuery?.data?._serverId || ''}
|
||||
/>
|
||||
),
|
||||
title: t('common.saveAs', { postProcess: 'sentenceCase' }),
|
||||
|
||||
@@ -74,7 +74,7 @@ export const useSetRating = (args: MutationHookArgs) => {
|
||||
if (remote) {
|
||||
remote.updateRating(
|
||||
variables.query.rating,
|
||||
variables.query.item[0].serverId,
|
||||
variables.query.item[0]._serverId,
|
||||
songIds,
|
||||
);
|
||||
}
|
||||
@@ -88,9 +88,9 @@ export const useSetRating = (args: MutationHookArgs) => {
|
||||
variables.query.item[0].itemType === LibraryItem.ALBUM;
|
||||
|
||||
if (isAlbumDetailPage) {
|
||||
const { id: albumId, serverId } = variables.query.item[0] as Album;
|
||||
const { id: albumId, _serverId } = variables.query.item[0] as Album;
|
||||
|
||||
const queryKey = queryKeys.albums.detail(serverId || '', { id: albumId });
|
||||
const queryKey = queryKeys.albums.detail(_serverId || '', { id: albumId });
|
||||
const previous = queryClient.getQueryData<AlbumDetailResponse>(queryKey);
|
||||
if (previous) {
|
||||
queryClient.setQueryData<AlbumDetailResponse>(queryKey, {
|
||||
|
||||
@@ -34,7 +34,7 @@ export const SimilarSongsList = ({ count, fullScreen, song }: SimilarSongsListPr
|
||||
count,
|
||||
songId: song.id,
|
||||
},
|
||||
serverId: song?.serverId,
|
||||
serverId: song?._serverId,
|
||||
}),
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user