mirror of
https://github.com/jeffvli/feishin.git
synced 2026-07-23 19:06:32 +02:00
Replace startScan (full library refresh) with refreshItem (individual item refresh) for jellyfin metadata editing
This commit is contained in:
@@ -864,15 +864,15 @@ export const controller: GeneralController = {
|
||||
server.type,
|
||||
)?.(addContext({ ...args, apiClientProps: { ...args.apiClientProps, server } }));
|
||||
},
|
||||
startScan(args) {
|
||||
refreshItems(args) {
|
||||
const server = getServerById(args.apiClientProps.serverId);
|
||||
|
||||
if (!server) {
|
||||
throw new Error(`${i18n.t('error.apiRouteError')}: startScan`);
|
||||
throw new Error(`${i18n.t('error.apiRouteError')}: refreshItems`);
|
||||
}
|
||||
|
||||
return apiController(
|
||||
'startScan',
|
||||
'refreshItems',
|
||||
server.type,
|
||||
)?.(addContext({ ...args, apiClientProps: { ...args.apiClientProps, server } }));
|
||||
},
|
||||
|
||||
@@ -365,11 +365,13 @@ export const contract = c.router({
|
||||
400: jfType._response.error,
|
||||
},
|
||||
},
|
||||
startScan: {
|
||||
refreshItem: {
|
||||
body: z.null(),
|
||||
method: 'POST',
|
||||
path: 'Library/Refresh',
|
||||
query: z.object({}),
|
||||
path: 'Items/:id/Refresh',
|
||||
query: z.object({
|
||||
MetadataRefreshMode: z.string().optional(),
|
||||
}),
|
||||
responses: {
|
||||
204: z.null(),
|
||||
400: jfType._response.error,
|
||||
|
||||
@@ -1931,17 +1931,18 @@ export const JellyfinController: InternalControllerEndpoint = {
|
||||
|
||||
return null;
|
||||
},
|
||||
startScan: async (args) => {
|
||||
const { apiClientProps } = args;
|
||||
refreshItems: async (args) => {
|
||||
const { apiClientProps, query } = args;
|
||||
|
||||
const res = await jfApiClient(apiClientProps).startScan({
|
||||
body: null,
|
||||
query: {},
|
||||
});
|
||||
|
||||
if (res.status !== 204) {
|
||||
throw new Error('Failed to start scan');
|
||||
}
|
||||
await Promise.all(
|
||||
query.ids.map((id) =>
|
||||
jfApiClient(apiClientProps).refreshItem({
|
||||
body: null,
|
||||
params: { id },
|
||||
query: { MetadataRefreshMode: 'FullRefresh' },
|
||||
}),
|
||||
),
|
||||
);
|
||||
|
||||
return null;
|
||||
},
|
||||
|
||||
@@ -1261,7 +1261,7 @@ export const NavidromeController: InternalControllerEndpoint = {
|
||||
id: res.body.data.id,
|
||||
};
|
||||
},
|
||||
startScan: SubsonicController.startScan,
|
||||
refreshItems: SubsonicController.refreshItems,
|
||||
updateInternetRadioStation: async (args) => {
|
||||
const { apiClientProps, body, query } = args;
|
||||
|
||||
|
||||
@@ -2461,7 +2461,7 @@ export const SubsonicController: InternalControllerEndpoint = {
|
||||
|
||||
return null;
|
||||
},
|
||||
startScan: async (args) => {
|
||||
refreshItems: async (args) => {
|
||||
const { apiClientProps } = args;
|
||||
|
||||
const res = await ssApiClient(apiClientProps).startScan({ query: {} });
|
||||
@@ -2470,7 +2470,7 @@ export const SubsonicController: InternalControllerEndpoint = {
|
||||
throw new Error('Failed to start scan');
|
||||
}
|
||||
|
||||
return res.body.scanStatus;
|
||||
return null;
|
||||
},
|
||||
updateInternetRadioStation: async (args) => {
|
||||
const { apiClientProps, body, query } = args;
|
||||
|
||||
@@ -286,7 +286,10 @@ export const useMetadataEditor = ({ browser, songs: songsProp, utils }: UseMetad
|
||||
|
||||
if (rescan && server) {
|
||||
try {
|
||||
await controller.startScan({ apiClientProps: { serverId: server.id } });
|
||||
await controller.refreshItems({
|
||||
apiClientProps: { serverId: server.id },
|
||||
query: { ids: resolvedSongs.map((s) => s.id) },
|
||||
});
|
||||
toast.success({ message: t('page.itemDetail.rescanStarted') });
|
||||
} catch {
|
||||
// non-fatal
|
||||
|
||||
Reference in New Issue
Block a user