Skip to content

Commit

Permalink
return total from API
Browse files Browse the repository at this point in the history
  • Loading branch information
ikreymer committed Feb 12, 2025
1 parent 5dc6141 commit 6daeaa7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -306,8 +306,8 @@ class API {
const pageSize = Number(params._query.get("pageSize")) || 25;
if (q) {
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
const pages = await coll.store.queryPages(q, page, pageSize);
return { pages };
const { pages, total } = await coll.store.queryPages(q, page, pageSize);
return { pages, total };
}
}
const pages = await coll.store.getAllPages();
Expand Down
14 changes: 8 additions & 6 deletions src/wacz/multiwacz.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1263,7 +1263,7 @@ export class MultiWACZ
page = 1,
pageSize = 25,
// eslint-disable-next-line @typescript-eslint/no-explicit-any
): Promise<Record<string, any>[]> {
): Promise<{pages: Record<string, any>[], total: number}> {
const params = new URLSearchParams();
params.set("search", search);
params.set("page", page + "");
Expand All @@ -1272,14 +1272,17 @@ export class MultiWACZ
headers: this.sourceLoader?.headers,
});
if (res.status !== 200) {
return [];
return {pages: [], total: 0};
}
const json = await res.json();
if (!json) {
return [];
return {pages: [], total: 0};
}

const total = json.total;

// eslint-disable-next-line @typescript-eslint/no-explicit-any
const pages = json.items.map((x: any) => {
const pages : Record<string, any>[] = json.items.map((x: any) => {
x.wacz = x.filename;
const file = this.waczfiles[x.filename];
if (file) {
Expand All @@ -1293,8 +1296,7 @@ export class MultiWACZ
return x;
});

// eslint-disable-next-line @typescript-eslint/no-unsafe-return
return pages;
return {pages, total};
}

async getWACZFilesToTry(request: ArchiveRequest, waczname: string | null) {
Expand Down

0 comments on commit 6daeaa7

Please sign in to comment.