feat(library) : search
This commit is contained in:
@@ -33,7 +33,8 @@ export class LibraryService extends BaseApiService {
|
||||
libraryId: string,
|
||||
page: number = 0,
|
||||
size: number = 20,
|
||||
unreadOnly: boolean = false
|
||||
unreadOnly: boolean = false,
|
||||
search?: string
|
||||
): Promise<LibraryResponse<Series>> {
|
||||
try {
|
||||
const config = await this.getKomgaConfig();
|
||||
@@ -42,11 +43,12 @@ export class LibraryService extends BaseApiService {
|
||||
page: page.toString(),
|
||||
size: size.toString(),
|
||||
...(unreadOnly && { read_status: "UNREAD,IN_PROGRESS" }),
|
||||
...(search && { search }),
|
||||
});
|
||||
const headers = this.getAuthHeaders(config);
|
||||
|
||||
return this.fetchWithCache<LibraryResponse<Series>>(
|
||||
`library-${libraryId}-series-${page}-${size}-${unreadOnly}`,
|
||||
`library-${libraryId}-series-${page}-${size}-${unreadOnly}-${search}`,
|
||||
async () => this.fetchFromApi<LibraryResponse<Series>>(url, headers),
|
||||
"SERIES"
|
||||
);
|
||||
@@ -56,6 +58,6 @@ export class LibraryService extends BaseApiService {
|
||||
}
|
||||
|
||||
static async clearLibrarySeriesCache(libraryId: string) {
|
||||
serverCacheService.delete(`library-${libraryId}-series`);
|
||||
serverCacheService.deleteAll(`library-${libraryId}-series`);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,3 +13,20 @@ export function formatDate(date: string | Date): string {
|
||||
year: "numeric",
|
||||
});
|
||||
}
|
||||
|
||||
export function debounce<T extends (...args: any[]) => void>(
|
||||
func: T,
|
||||
wait: number
|
||||
): (...args: Parameters<T>) => void {
|
||||
let timeout: NodeJS.Timeout;
|
||||
|
||||
return function executedFunction(...args: Parameters<T>) {
|
||||
const later = () => {
|
||||
clearTimeout(timeout);
|
||||
func(...args);
|
||||
};
|
||||
|
||||
clearTimeout(timeout);
|
||||
timeout = setTimeout(later, wait);
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user