Skip to content

Commit 8304eee

Browse files
committed
allow 'show non-seed pages' for dynamic querying
1 parent 2c57caa commit 8304eee

File tree

2 files changed

+24
-8
lines changed

2 files changed

+24
-8
lines changed

src/pages.ts

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -228,13 +228,20 @@ class Pages extends LitElement {
228228
);
229229
} else if (this.showAllPages && this.hasExtraPages) {
230230
this.filteredPages = [...this.textPages!];
231-
} else {
231+
} else if (!this.dynamicPagesQuery) {
232232
this.filteredPages = [...this.collInfo!.pages];
233233
}
234234

235235
this.totalPages = this.filteredPages.length;
236236

237237
if (this.dynamicPagesQuery) {
238+
if (!this.query) {
239+
const seedPages = this.collInfo!.pages.filter((x) => x.isSeed);
240+
this.filteredPages = this.showAllPages
241+
? [...this.collInfo!.pages]
242+
: seedPages;
243+
this.hasExtraPages = seedPages.length !== this.collInfo!.pages.length;
244+
}
238245
this.dynamicPageCount = 1;
239246
await this.addDynamicPages();
240247
}
@@ -289,11 +296,16 @@ class Pages extends LitElement {
289296
ts,
290297
favIconUrl,
291298
waczhash,
299+
isSeed,
292300
} of json.pages) {
293301
if (knownPages.has(id)) {
294302
continue;
295303
}
296304

305+
if (!this.showAllPages && !isSeed) {
306+
continue;
307+
}
308+
297309
let tsActual;
298310

299311
if (typeof ts === "string") {
@@ -353,11 +365,13 @@ class Pages extends LitElement {
353365
this.flex = flex;
354366
this.textPages = pages;
355367

356-
this.hasExtraPages = Boolean(
357-
this.textPages &&
358-
this.collInfo?.pages &&
359-
this.textPages.length > this.collInfo.pages.length,
360-
);
368+
if (!this.dynamicPagesQuery) {
369+
this.hasExtraPages = Boolean(
370+
this.textPages &&
371+
this.collInfo?.pages &&
372+
this.textPages.length > this.collInfo.pages.length,
373+
);
374+
}
361375

362376
if (this.collInfo) {
363377
this.dynamicPagesQuery = this.collInfo.canQueryPages || false;

src/types.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ export type URLResource = {
1414
waczhash?: string;
1515
};
1616

17-
export type Page = URLResource;
17+
export type Page = URLResource & {
18+
isSeed?: boolean;
19+
};
1820

1921
export type ItemType = {
2022
filename?: string;
@@ -44,7 +46,7 @@ export type ItemType = {
4446
software?: string;
4547
};
4648
onDemand?: boolean;
47-
pages: URLResource[];
49+
pages: Page[];
4850
curatedPages: (URLResource & { list: string })[];
4951
lists: URLResource[];
5052
ctime?: string;

0 commit comments

Comments
 (0)