mirror of
https://github.com/idanoo/autobrr
synced 2025-07-24 01:09:13 +00:00
* refactor(APIClient): updated the newly added findQuery function to use URLSearchParams instead of manually crafting the URI string itself. * refactor: moved duplicate dashboard/release code to a separate folder: components/data-table. * refactor(SlideOver): added proper typings to the SlideOver component and added a sanity check to prevent passing of null/undefined values to the child component before rendering. * refactor: removed the redundant Network and Channel typings and updated relevant typings to match the backend. adapted relevant code to match these changes. * fix(ChannelsFieldArray): fixed a bug where it was unable to add a new irc network due to the validation object being initialized as non-empty (formik requires that successful validated entries return empty objects) * refactor(screens/settings/Irc): replaced incorrect typings, sanitized potentially null values and cleaned up the code. * fix: included changes should fix issue #158 as well. * feat: send chan empty array
This commit is contained in:
parent
5a45851677
commit
9ea29d02a2
23 changed files with 974 additions and 1187 deletions
|
@ -87,9 +87,9 @@ export const APIClient = {
|
|||
delete: (id: number) => appClient.Delete(`api/indexer/${id}`),
|
||||
},
|
||||
irc: {
|
||||
getNetworks: () => appClient.Get<IrcNetwork[]>("api/irc"),
|
||||
createNetwork: (network: Network) => appClient.Post("api/irc", network),
|
||||
updateNetwork: (network: Network) => appClient.Put(`api/irc/network/${network.id}`, network),
|
||||
getNetworks: () => appClient.Get<IrcNetworkWithHealth[]>("api/irc"),
|
||||
createNetwork: (network: IrcNetwork) => appClient.Post("api/irc", network),
|
||||
updateNetwork: (network: IrcNetwork) => appClient.Put(`api/irc/network/${network.id}`, network),
|
||||
deleteNetwork: (id: number) => appClient.Delete(`api/irc/network/${id}`),
|
||||
},
|
||||
events: {
|
||||
|
@ -97,28 +97,25 @@ export const APIClient = {
|
|||
},
|
||||
release: {
|
||||
find: (query?: string) => appClient.Get<ReleaseFindResponse>(`api/release${query}`),
|
||||
findQuery: (offset?: number, limit?: number, filters?: any[]) => {
|
||||
let queryString = "?"
|
||||
findQuery: (offset?: number, limit?: number, filters?: Array<ReleaseFilter>) => {
|
||||
const params = new URLSearchParams();
|
||||
if (offset !== undefined)
|
||||
params.append("offset", offset.toString());
|
||||
|
||||
if (offset != 0) {
|
||||
queryString += `offset=${offset}`
|
||||
}
|
||||
if (limit != 0) {
|
||||
queryString += `&limit=${limit}`
|
||||
}
|
||||
if (filters && filters?.length > 0) {
|
||||
filters?.map((filter) => {
|
||||
if (filter.id === "indexer" && filter.value != "") {
|
||||
queryString += `&indexer=${filter.value}`
|
||||
}
|
||||
// using action_status instead of push_status because thats the column accessor
|
||||
if (filter.id === "action_status" && filter.value != "") {
|
||||
queryString += `&push_status=${filter.value}`
|
||||
}
|
||||
})
|
||||
}
|
||||
if (limit !== undefined)
|
||||
params.append("limit", limit.toString());
|
||||
|
||||
return appClient.Get<ReleaseFindResponse>(`api/release${queryString}`)
|
||||
filters?.forEach((filter) => {
|
||||
if (!filter.value)
|
||||
return;
|
||||
|
||||
if (filter.id == "indexer")
|
||||
params.append("indexer", filter.value);
|
||||
else if (filter.id === "action_status")
|
||||
params.append("push_status", filter.value);
|
||||
});
|
||||
|
||||
return appClient.Get<ReleaseFindResponse>(`api/release?${params.toString()}`)
|
||||
},
|
||||
indexerOptions: () => appClient.Get<string[]>(`api/release/indexers`),
|
||||
stats: () => appClient.Get<ReleaseStats>("api/release/stats")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue