Extract generic useListData hook for shared list fetching

This commit is contained in:
2026-04-21 17:53:58 +02:00
parent e683108965
commit e244a85291
9 changed files with 232 additions and 169 deletions

View File

@@ -21,8 +21,8 @@ import type {
// ---------------------------------------------------------------------------
/** Fetch all configured blocklist sources. */
export async function fetchBlocklists(): Promise<BlocklistListResponse> {
return get<BlocklistListResponse>(ENDPOINTS.blocklists);
export async function fetchBlocklists(signal?: AbortSignal): Promise<BlocklistListResponse> {
return get<BlocklistListResponse>(ENDPOINTS.blocklists, signal);
}
/** Create a new blocklist source. */

View File

@@ -51,8 +51,9 @@ import type {
// ---------------------------------------------------------------------------
export async function fetchJailConfigs(
signal?: AbortSignal,
): Promise<JailConfigListResponse> {
return get<JailConfigListResponse>(ENDPOINTS.configJails);
return get<JailConfigListResponse>(ENDPOINTS.configJails, signal);
}
export async function fetchJailConfig(
@@ -344,8 +345,8 @@ export async function assignFilterToJail(
*
* @returns FilterListResponse with all discovered filters and status.
*/
export async function fetchFilters(): Promise<FilterListResponse> {
return get<FilterListResponse>(ENDPOINTS.configFilters);
export async function fetchFilters(signal?: AbortSignal): Promise<FilterListResponse> {
return get<FilterListResponse>(ENDPOINTS.configFilters, signal);
}
/**
@@ -385,8 +386,8 @@ export async function updateParsedAction(
*
* @returns ActionListResponse with all discovered actions and status.
*/
export async function fetchActions(): Promise<ActionListResponse> {
return get<ActionListResponse>(ENDPOINTS.configActions);
export async function fetchActions(signal?: AbortSignal): Promise<ActionListResponse> {
return get<ActionListResponse>(ENDPOINTS.configActions, signal);
}
/**