Project started 🥂
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
import { api } from '../index';
|
||||
import type { DownloadJob } from '../types';
|
||||
|
||||
export const downloadsApi = api.injectEndpoints({
|
||||
endpoints: (build) => ({
|
||||
getDownloads: build.query<DownloadJob[], { status?: DownloadJob['status'] } | void>({
|
||||
query: (params) => ({ url: '/downloads', params: params ?? {} }),
|
||||
providesTags: ['Download'],
|
||||
}),
|
||||
addDownload: build.mutation<DownloadJob, { url: string; metadata?: { title?: string; artist?: string; album?: string } }>({
|
||||
query: (body) => ({ url: '/downloads', method: 'POST', body }),
|
||||
invalidatesTags: ['Download'],
|
||||
}),
|
||||
cancelDownload: build.mutation<void, string>({
|
||||
query: (id) => ({ url: `/downloads/${id}`, method: 'DELETE' }),
|
||||
invalidatesTags: ['Download'],
|
||||
}),
|
||||
retryDownload: build.mutation<DownloadJob, string>({
|
||||
query: (id) => ({ url: `/downloads/${id}/retry`, method: 'POST' }),
|
||||
invalidatesTags: ['Download'],
|
||||
}),
|
||||
}),
|
||||
overrideExisting: false,
|
||||
});
|
||||
|
||||
export const { useGetDownloadsQuery, useAddDownloadMutation, useCancelDownloadMutation, useRetryDownloadMutation } = downloadsApi;
|
||||
Reference in New Issue
Block a user