Keep open-tab updates pagination handling unchanged

This commit is contained in:
Peter White
2026-11-26 21:23:42 +00:00
parent c22c1214b7
commit 49aa9bfdcf
5 changed files with 4 additions and 35 deletions
+1 -1
View File
@@ -2,4 +2,4 @@
"gitbook": patch
---
Restrict updates pagination to single top-level Updates blocks and preserve active tag filters when a page stops paginating.
Restrict updates pagination to single top-level Updates blocks.
@@ -260,11 +260,6 @@ function useFilteredUpdatesView(options: {
}
const url = new URL(window.location.href);
if (result.status === 'unpaginated') {
setUpdatesPageParam(url.searchParams, 1);
reloadToURL(url);
return;
}
if (result.status === 'unfiltered') {
url.searchParams.delete(UPDATES_FILTER_SEARCH_PARAM);
setUpdatesPageParam(url.searchParams, initialPage);
@@ -344,12 +339,6 @@ function useResolveUpdatesAnchor(options: {
return;
}
if (result.page === null) {
setUpdatesPageParam(url.searchParams, 1);
reloadToURL(url);
return;
}
setUpdatesPageParam(url.searchParams, result.page);
if (result.clearTags) {
url.searchParams.delete(UPDATES_FILTER_SEARCH_PARAM);
@@ -417,14 +406,6 @@ function findScrollContainer(element: HTMLElement | null): HTMLElement | null {
return null;
}
function reloadToURL(url: URL) {
if (url.href === window.location.href) {
window.location.reload();
return;
}
window.location.replace(relativeURL(url));
}
function relativeURL(url: URL): string {
return `${url.pathname}${url.search}${url.hash}`;
}
@@ -41,10 +41,6 @@ export type FilteredUpdatesPageResult =
status: 'unfiltered';
revisionId: string;
}
| {
status: 'unpaginated';
revisionId: string;
}
| {
status: 'error';
};
@@ -74,7 +70,7 @@ export async function getFilteredUpdatesPage(
});
if (!result.pagination) {
logger.info('Current revision no longer needs updates pagination', { pageId: page.id });
return { status: 'unpaginated', revisionId: context.revisionId };
return { status: 'unfiltered', revisionId: context.revisionId };
}
const [sections, iconSources] = await Promise.all([
@@ -121,7 +117,7 @@ export async function resolveUpdatesAnchor(options: UpdatesPageAction & { anchor
found: result.found,
page: result.found && result.page,
});
if (result.found && (result.page === null || result.page <= UPDATES_MAX_PAGE)) {
if (result.found && result.page <= UPDATES_MAX_PAGE) {
return result;
}
} catch {
-5
View File
@@ -331,11 +331,6 @@ function expectNotPaginated(document: JSONDocument, eligibility: UpdatesPaginati
});
expect(result.document).toBe(document);
expect(findUpdateAnchorPage(document, undefined, { anchor: 'update-1' })).toEqual({
found: true,
page: null,
clearTags: false,
});
expect(findUpdateAnchorPage(document, undefined, { anchor: 'missing' })).toEqual({
found: false,
});
}
+1 -4
View File
@@ -252,12 +252,9 @@ export function findUpdateAnchorPage(
document: JSONDocument,
revision: Revision | undefined,
{ anchor, tags }: { anchor: string; tags?: string[] }
): { found: true; page: number | null; clearTags: boolean } | { found: false } {
): { found: true; page: number; clearTags: boolean } | { found: false } {
const eligibility = getUpdatesPaginationEligibility(document);
if (eligibility.status !== 'eligible') {
if (hasMoreThan(document, (node) => matchesUpdateAnchor(node, anchor), 0)) {
return { found: true, page: null, clearTags: false };
}
return { found: false };
}