mirror of
https://github.com/jeffvli/feishin.git
synced 2026-05-14 12:30:06 +02:00
handle favorite/rating column mutations
This commit is contained in:
@@ -4,6 +4,7 @@ import isElectron from 'is-electron';
|
||||
|
||||
import { api } from '/@/renderer/api';
|
||||
import { queryKeys } from '/@/renderer/api/query-keys';
|
||||
import { eventEmitter } from '/@/renderer/events/event-emitter';
|
||||
import { MutationHookArgs } from '/@/renderer/lib/react-query';
|
||||
import { useSetAlbumListItemDataById } from '/@/renderer/store';
|
||||
import { useFavoriteEvent } from '/@/renderer/store/event.store';
|
||||
@@ -31,6 +32,22 @@ export const useCreateFavorite = (args: MutationHookArgs) => {
|
||||
apiClientProps: { serverId: args.apiClientProps.serverId },
|
||||
});
|
||||
},
|
||||
onError: (_error, variables) => {
|
||||
eventEmitter.emit('USER_FAVORITE', {
|
||||
favorite: false,
|
||||
id: variables.query.id,
|
||||
itemType: variables.query.type,
|
||||
});
|
||||
},
|
||||
onMutate: (variables) => {
|
||||
eventEmitter.emit('USER_FAVORITE', {
|
||||
favorite: true,
|
||||
id: variables.query.id,
|
||||
itemType: variables.query.type,
|
||||
});
|
||||
|
||||
return null;
|
||||
},
|
||||
onSuccess: (_data, variables) => {
|
||||
const { apiClientProps } = variables;
|
||||
const serverId = apiClientProps.serverId;
|
||||
|
||||
Reference in New Issue
Block a user