mirror of
https://github.com/jeffvli/feishin.git
synced 2026-05-08 21:10:12 +02:00
Add remote control (#164)
* draft add remotes * add favorite, rating * add basic auth
This commit is contained in:
@@ -11,6 +11,9 @@ import {
|
||||
} from '/@/renderer/api/types';
|
||||
import { MutationHookArgs } from '/@/renderer/lib/react-query';
|
||||
import { getServerById, useSetAlbumListItemDataById, useSetQueueFavorite } from '/@/renderer/store';
|
||||
import isElectron from 'is-electron';
|
||||
|
||||
const remote = isElectron() ? window.electron.remote : null;
|
||||
|
||||
export const useCreateFavorite = (args: MutationHookArgs) => {
|
||||
const { options } = args || {};
|
||||
@@ -42,6 +45,7 @@ export const useCreateFavorite = (args: MutationHookArgs) => {
|
||||
}
|
||||
|
||||
if (variables.query.type === LibraryItem.SONG) {
|
||||
remote?.updateFavorite(true, serverId, variables.query.id);
|
||||
setQueueFavorite(variables.query.id, true);
|
||||
}
|
||||
|
||||
|
||||
@@ -11,6 +11,9 @@ import {
|
||||
} from '/@/renderer/api/types';
|
||||
import { MutationHookArgs } from '/@/renderer/lib/react-query';
|
||||
import { getServerById, useSetAlbumListItemDataById, useSetQueueFavorite } from '/@/renderer/store';
|
||||
import isElectron from 'is-electron';
|
||||
|
||||
const remote = isElectron() ? window.electron.remote : null;
|
||||
|
||||
export const useDeleteFavorite = (args: MutationHookArgs) => {
|
||||
const { options } = args || {};
|
||||
@@ -42,6 +45,7 @@ export const useDeleteFavorite = (args: MutationHookArgs) => {
|
||||
}
|
||||
|
||||
if (variables.query.type === LibraryItem.SONG) {
|
||||
remote?.updateFavorite(false, serverId, variables.query.id);
|
||||
setQueueFavorite(variables.query.id, false);
|
||||
}
|
||||
|
||||
|
||||
@@ -14,6 +14,9 @@ import {
|
||||
} from '/@/renderer/api/types';
|
||||
import { MutationHookArgs } from '/@/renderer/lib/react-query';
|
||||
import { getServerById, useSetAlbumListItemDataById, useSetQueueRating } from '/@/renderer/store';
|
||||
import isElectron from 'is-electron';
|
||||
|
||||
const remote = isElectron() ? window.electron.remote : null;
|
||||
|
||||
export const useSetRating = (args: MutationHookArgs) => {
|
||||
const { options } = args || {};
|
||||
@@ -56,6 +59,11 @@ export const useSetRating = (args: MutationHookArgs) => {
|
||||
}
|
||||
}
|
||||
|
||||
if (remote) {
|
||||
const ids = variables.query.item.map((item) => item.id);
|
||||
remote.updateRating(variables.query.rating, variables.query.item[0].serverId, ids);
|
||||
}
|
||||
|
||||
return { previous: { items: variables.query.item } };
|
||||
},
|
||||
onSuccess: (_data, variables) => {
|
||||
|
||||
Reference in New Issue
Block a user