30 lines
871 B
TypeScript
30 lines
871 B
TypeScript
import { api } from '../index';
|
|
import type { StorageStats } from '../types';
|
|
|
|
export const storageApi = api.injectEndpoints({
|
|
endpoints: (build) => ({
|
|
getStorageStats: build.query<StorageStats, void>({
|
|
query: () => '/storage/stats',
|
|
providesTags: ['Storage'],
|
|
}),
|
|
scanStorage: build.mutation<{ jobId: string }, void>({
|
|
query: () => ({ url: '/storage/scan', method: 'POST' }),
|
|
invalidatesTags: ['Storage', 'Track', 'Album', 'Artist'],
|
|
}),
|
|
deleteTrackFile: build.mutation<void, string>({
|
|
query: (trackId) => ({
|
|
url: `/storage/tracks/${trackId}`,
|
|
method: 'DELETE',
|
|
}),
|
|
invalidatesTags: ['Storage', { type: 'Track', id: undefined }],
|
|
}),
|
|
}),
|
|
overrideExisting: false,
|
|
});
|
|
|
|
export const {
|
|
useGetStorageStatsQuery,
|
|
useScanStorageMutation,
|
|
useDeleteTrackFileMutation,
|
|
} = storageApi;
|