mirror of
https://github.com/jeffvli/feishin.git
synced 2026-05-16 13:40:24 +02:00
28 lines
1.0 KiB
TypeScript
28 lines
1.0 KiB
TypeScript
import { useMutation } from '@tanstack/react-query';
|
|
import { AxiosError } from 'axios';
|
|
|
|
import { api } from '/@/renderer/api';
|
|
import { MutationOptions } from '/@/renderer/lib/react-query';
|
|
import { ScrobbleArgs, ScrobbleResponse } from '/@/shared/types/domain-types';
|
|
|
|
export const useSendScrobble = (options?: MutationOptions) => {
|
|
// const incrementPlayCount = useIncrementQueuePlayCount();
|
|
|
|
return useMutation<ScrobbleResponse, AxiosError, ScrobbleArgs, null>({
|
|
mutationFn: (args) => {
|
|
return api.controller.scrobble({
|
|
...args,
|
|
apiClientProps: { serverId: args.apiClientProps.serverId },
|
|
});
|
|
},
|
|
onSuccess: (_data, variables) => {
|
|
// 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);
|
|
}
|
|
},
|
|
...options,
|
|
});
|
|
};
|