Repository navigation
fix(help-center): translate the portal, gate the Help tab, use the write's tally, and page a section #271
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(help-center): translate the portal, gate the Help tab, use the write's tally, and page a section #271
Changes from all commits
301164d
69fec3c
fa4636a
a43945b
8c9e7a5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -715,13 +715,28 @@ export function helpCenterArticlesQueryKey( | |
| return organizationScopedKey(organizationId, "help-center-article"); | ||
| } | ||
|
|
||
| /** | ||
| * How many articles one section page loads at a time. | ||
| * | ||
| * The live query asks the server for one more than this — the peek row that | ||
| * says whether there is another page — and hides it. `Load more` widens the | ||
| * window rather than fetching after a cursor, so the request grows by this much | ||
| * per page; the list's own ceiling is what stops it. | ||
| */ | ||
| export const HELP_CENTER_SECTION_ARTICLE_PAGE_SIZE = 25; | ||
|
|
||
| /** | ||
| * The query key for one section's articles. | ||
| * | ||
| * The section page's collection and the editor's post-write invalidation both | ||
| * name the same rows, so the key is derived here rather than spelled twice. A | ||
| * drift between the two would leave the section page showing the article as it | ||
| * was before the save. | ||
| * | ||
| * It is the section's prefix, not a page: the on-demand collection appends the | ||
| * `LoadSubsetOptions` it is asked for (the window and the filters) to this key, | ||
| * which is what gives each page its own cache entry while the editor can still | ||
| * invalidate every page of a section by its prefix. | ||
| */ | ||
| export function helpCenterArticleTopicQueryKey( | ||
| organizationId: string | undefined, | ||
|
|
@@ -736,14 +751,19 @@ export function helpCenterArticleTopicQueryKey( | |
| } | ||
|
|
||
| /** | ||
| * One section's articles. | ||
| * One section's articles, one page at a time. | ||
| * | ||
| * A section page lists one topic, and the workspace-wide | ||
| * `helpCenterArticleCollection` stays for `useWorkspaceUsage` only. Scoping the | ||
| * collection by topic is what lets the editor invalidate exactly the lists a | ||
| * write could have changed, including both lists when an article moves | ||
| * sections. The operation filters by `topicId` on the server; the live query | ||
| * keeps its predicate as a second guard. | ||
| * sections. | ||
| * | ||
| * `on-demand` because the page asks for a window: the live query passes its | ||
| * `offset`/`limit` down to `queryFn`, and the server returns that page in the | ||
| * order `sort: "updated"` names. The section page must order by the same two | ||
| * columns the repository sorts by, or a window would be cut from one order and | ||
| * rendered in another. | ||
| */ | ||
| export function helpCenterTopicArticleCollection( | ||
| scope: DashboardCollectionScope, | ||
|
|
@@ -758,27 +778,46 @@ export function helpCenterTopicArticleCollection( | |
| queryCollectionOptions({ | ||
| id, | ||
| queryClient: client.requireDependency<QueryClient>("queryClient"), | ||
| queryKey: () => | ||
| helpCenterArticleTopicQueryKey(scope.organizationId, topicId), | ||
| queryKey: helpCenterArticleTopicQueryKey(scope.organizationId, topicId), | ||
| queryFn: async (ctx) => { | ||
| const organizationId = scope.organizationId; | ||
|
|
||
| if (!organizationId) { | ||
| return []; | ||
| } | ||
|
|
||
| // The list operation filters by workspace and optionally one section; | ||
| // the section's live query keeps its predicate as a second guard, but | ||
| // the rows never leave the server. The workspace-wide collection stays | ||
| // for the plan-usage meter. | ||
| const window = ctx.meta?.loadSubsetOptions; | ||
|
|
||
| // The page windows every read, and the operation refuses a | ||
| // section-scoped list without one: a demand that named no window would | ||
| // ask the server for the whole section, which is the read this | ||
| // collection exists to avoid. It fails there rather than quietly | ||
| // returning a page a windowless demander would take as complete. | ||
| // | ||
| // The list operation filters by workspace and section on the server; | ||
| // the live query keeps its predicate as a second guard. The | ||
| // workspace-wide collection stays for the plan-usage meter, which is | ||
| // the one caller allowed to read without a window. | ||
| const data = await fetchRpc( | ||
| (rpc) => rpc.ListHelpCenterArticles({ organizationId, topicId }), | ||
| (rpc) => | ||
| rpc.ListHelpCenterArticles({ | ||
| organizationId, | ||
| sort: "updated", | ||
| topicId, | ||
| ...(window?.limit === undefined | ||
| ? undefined | ||
| : { limit: window.limit }), | ||
|
Comment on lines
+807
to
+809
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Limit the section RPC to the requested rows, or avoid boundary requests. On-demand windows can send a boundary request with a The live query still filters the returned rows on the client, so the displayed rows stay correct. The cost is the extra read. Choose one fix. Either forward the boundary predicate so the RPC returns only the boundary rows, or change the paging contract so this collection does not produce boundary requests. Keep the separate unrestricted usage-meter read.
|
||
| ...(window?.offset === undefined | ||
| ? undefined | ||
| : { offset: window.offset }), | ||
| }), | ||
| { signal: ctx.signal } | ||
| ); | ||
|
|
||
| return [...data]; | ||
| }, | ||
| getKey: (item) => item.id, | ||
| syncMode: "on-demand", | ||
| }) | ||
| ); | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Keep the final section-page request within the 500-row limit.
Each section page requests one row more than its page size so the list can tell whether another page exists. For a section with 476–500 articles, the twentieth page requests
limit=501.ListHelpCenterArticlesrejects alimitabove 500. That request fails, so the list stops at 475 articles. Retry sends the same request and fails again. Articles 476 to 500 cannot be reached.Keep every request limit at or below 500. A section with exactly 500 articles must still load all of its rows on the last page.