add favorite songs section to artist page (#1604)

This commit is contained in:
jeffvli
2026-02-02 22:23:38 -08:00
parent 50c3dbc0a0
commit ac5611fdca
16 changed files with 545 additions and 43 deletions
@@ -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,
});
};