mirror of
https://github.com/jeffvli/feishin.git
synced 2026-06-10 14:22:46 +02:00
add favorite songs section to artist page (#1604)
This commit is contained in:
@@ -41,6 +41,7 @@ interface HeaderPlayButtonProps {
|
||||
|
||||
interface TitleProps {
|
||||
children: ReactNode;
|
||||
order?: number;
|
||||
}
|
||||
|
||||
const HeaderPlayButton = ({
|
||||
@@ -100,9 +101,9 @@ const HeaderPlayButton = ({
|
||||
);
|
||||
};
|
||||
|
||||
const Title = ({ children }: TitleProps) => {
|
||||
const Title = ({ children, order = 1 }: TitleProps) => {
|
||||
return (
|
||||
<TextTitle fw={700} order={1} overflow="hidden">
|
||||
<TextTitle fw={700} order={order as any} overflow="hidden">
|
||||
{children}
|
||||
</TextTitle>
|
||||
);
|
||||
|
||||
@@ -4,6 +4,7 @@ import isElectron from 'is-electron';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
import { api } from '/@/renderer/api';
|
||||
import { queryKeys } from '/@/renderer/api/query-keys';
|
||||
import { eventEmitter } from '/@/renderer/events/event-emitter';
|
||||
import {
|
||||
applyFavoriteOptimisticUpdates,
|
||||
@@ -63,6 +64,17 @@ export const useCreateFavorite = (args: MutationHookArgs) => {
|
||||
if (variables.query.type === LibraryItem.SONG) {
|
||||
remote?.updateFavorite(true, variables.apiClientProps.serverId, variables.query.id);
|
||||
}
|
||||
if (
|
||||
variables.query.type === LibraryItem.SONG ||
|
||||
variables.query.type === LibraryItem.PLAYLIST_SONG ||
|
||||
variables.query.type === LibraryItem.QUEUE_SONG
|
||||
) {
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: queryKeys.albumArtists.favoriteSongs(
|
||||
variables.apiClientProps.serverId,
|
||||
),
|
||||
});
|
||||
}
|
||||
},
|
||||
...options,
|
||||
});
|
||||
|
||||
@@ -4,6 +4,7 @@ import isElectron from 'is-electron';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
import { api } from '/@/renderer/api';
|
||||
import { queryKeys } from '/@/renderer/api/query-keys';
|
||||
import { eventEmitter } from '/@/renderer/events/event-emitter';
|
||||
import {
|
||||
applyFavoriteOptimisticUpdates,
|
||||
@@ -67,6 +68,17 @@ export const useDeleteFavorite = (args: MutationHookArgs) => {
|
||||
variables.query.id,
|
||||
);
|
||||
}
|
||||
if (
|
||||
variables.query.type === LibraryItem.SONG ||
|
||||
variables.query.type === LibraryItem.PLAYLIST_SONG ||
|
||||
variables.query.type === LibraryItem.QUEUE_SONG
|
||||
) {
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: queryKeys.albumArtists.favoriteSongs(
|
||||
variables.apiClientProps.serverId,
|
||||
),
|
||||
});
|
||||
}
|
||||
},
|
||||
...options,
|
||||
});
|
||||
|
||||
@@ -3,6 +3,7 @@ import { AxiosError } from 'axios';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
import { api } from '/@/renderer/api';
|
||||
import { queryKeys } from '/@/renderer/api/query-keys';
|
||||
import { eventEmitter } from '/@/renderer/events/event-emitter';
|
||||
import { PreviousQueryData } from '/@/renderer/features/shared/mutations/favorite-optimistic-updates';
|
||||
import {
|
||||
@@ -11,7 +12,7 @@ import {
|
||||
} from '/@/renderer/features/shared/mutations/rating-optimistic-updates';
|
||||
import { MutationHookArgs } from '/@/renderer/lib/react-query';
|
||||
import { toast } from '/@/shared/components/toast/toast';
|
||||
import { RatingResponse, SetRatingArgs } from '/@/shared/types/domain-types';
|
||||
import { LibraryItem, RatingResponse, SetRatingArgs } from '/@/shared/types/domain-types';
|
||||
|
||||
const setRatingMutationKey = ['set-rating'];
|
||||
|
||||
@@ -56,6 +57,19 @@ export const useSetRatingMutation = (args: MutationHookArgs) => {
|
||||
|
||||
return applyRatingOptimisticUpdates(queryClient, variables, variables.query.rating);
|
||||
},
|
||||
onSuccess: (_data, variables) => {
|
||||
if (
|
||||
variables.query.type === LibraryItem.SONG ||
|
||||
variables.query.type === LibraryItem.PLAYLIST_SONG ||
|
||||
variables.query.type === LibraryItem.QUEUE_SONG
|
||||
) {
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: queryKeys.albumArtists.favoriteSongs(
|
||||
variables.apiClientProps.serverId,
|
||||
),
|
||||
});
|
||||
}
|
||||
},
|
||||
...options,
|
||||
});
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user