add optimistic update for favorite/ratings mutations

This commit is contained in:
jeffvli
2025-11-23 03:40:53 -08:00
parent 0bc3ea51ec
commit 84419820b8
19 changed files with 975 additions and 324 deletions
@@ -3,12 +3,10 @@ import { AxiosError } from 'axios';
import { api } from '/@/renderer/api';
import { MutationOptions } from '/@/renderer/lib/react-query';
import { usePlayEvent } from '/@/renderer/store/event.store';
import { ScrobbleArgs, ScrobbleResponse } from '/@/shared/types/domain-types';
export const useSendScrobble = (options?: MutationOptions) => {
// const incrementPlayCount = useIncrementQueuePlayCount();
const sendPlayEvent = usePlayEvent();
return useMutation<ScrobbleResponse, AxiosError, ScrobbleArgs, null>({
mutationFn: (args) => {
@@ -21,7 +19,7 @@ export const useSendScrobble = (options?: MutationOptions) => {
// Manually increment the play count for the song in the queue if scrobble was submitted
if (variables.query.submission) {
// incrementPlayCount([variables.query.id]);
sendPlayEvent(variables.query.id);
// sendPlayEvent(variables.query.id);
}
},
...options,