mirror of
https://github.com/antebudimir/feishin.git
synced 2026-03-02 12:17:25 +00:00
Add favoriting from context menu
This commit is contained in:
parent
f4f06abd72
commit
0aa0e51daa
5 changed files with 94 additions and 9 deletions
|
|
@ -4,3 +4,5 @@ export * from './components/play-button';
|
|||
export * from './utils';
|
||||
export * from './components/library-header';
|
||||
export * from './components/library-header-bar';
|
||||
export * from './mutations/create-favorite-mutation';
|
||||
export * from './mutations/delete-favorite-mutation';
|
||||
|
|
|
|||
|
|
@ -0,0 +1,15 @@
|
|||
import { useMutation } from '@tanstack/react-query';
|
||||
import { HTTPError } from 'ky';
|
||||
import { api } from '/@/renderer/api';
|
||||
import { FavoriteArgs, RawFavoriteResponse } from '/@/renderer/api/types';
|
||||
import { MutationOptions } from '/@/renderer/lib/react-query';
|
||||
import { useCurrentServer } from '/@/renderer/store';
|
||||
|
||||
export const useCreateFavorite = (options?: MutationOptions) => {
|
||||
const server = useCurrentServer();
|
||||
|
||||
return useMutation<RawFavoriteResponse, HTTPError, Omit<FavoriteArgs, 'server'>, null>({
|
||||
mutationFn: (args) => api.controller.createFavorite({ ...args, server }),
|
||||
...options,
|
||||
});
|
||||
};
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
import { useMutation } from '@tanstack/react-query';
|
||||
import { HTTPError } from 'ky';
|
||||
import { api } from '/@/renderer/api';
|
||||
import { FavoriteArgs, RawFavoriteResponse } from '/@/renderer/api/types';
|
||||
import { MutationOptions } from '/@/renderer/lib/react-query';
|
||||
import { useCurrentServer } from '/@/renderer/store';
|
||||
|
||||
export const useDeleteFavorite = (options?: MutationOptions) => {
|
||||
const server = useCurrentServer();
|
||||
|
||||
return useMutation<RawFavoriteResponse, HTTPError, Omit<FavoriteArgs, 'server'>, null>({
|
||||
mutationFn: (args) => api.controller.deleteFavorite({ ...args, server }),
|
||||
...options,
|
||||
});
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue