3131 * - the discussion and the activity → the page's feed, which takes them
3232 * from the payload (`recordPageComments` / `recordPageActivity`) instead
3333 * of reading `sys_comment`, `sys_comment_reaction` and `sys_activity`
34- * (objectstack#28470).
34+ * (objectstack#28470);
35+ * - the 动态 stream's count → the page's 动态 count (`recordPageTimeline`),
36+ * so the page asks only the activity rows the 动态 panel draws
37+ * (objectstack#28737).
3538 *
3639 * Each related list names the lookups of its rows to resolve (`expand`), as
3740 * the list's own read does, so the rows carry the names the list draws and no
@@ -70,10 +73,12 @@ import { seedRecordApprovals, type ApprovalRequestLite } from '../hooks/useRecor
7073const MAX_RELATED = 50 ;
7174
7275/**
73- * How many activity rows the page asks (objectstack#28470): the window the
74- * record feed always read (`$top: 200`). The 动态 panel draws the newest few,
75- * but its count and the 动态 tab are the whole merged stream the page holds,
76- * so the page asks the window the stream is drawn from, not the panel's peek.
76+ * The activity window the record feed reads (`$top: 200`, objectstack#28470):
77+ * what the 动态 tab draws in full, and what a page asks when it opens on a
78+ * face that draws the whole stream. A page that opens on the 动态 panel asks
79+ * only the rows the panel draws, and the stream's count comes with it
80+ * (`timeline`, objectstack#28737); the 动态 tab reads this window when it
81+ * opens.
7782 */
7883export const RECORD_PAGE_ACTIVITY_ROWS = 200 ;
7984
@@ -210,6 +215,8 @@ export function recordPageRequestOf(plan: {
210215 activity ?: number ;
211216 /** How many attachments, when the page draws them. */
212217 attachments ?: number ;
218+ /** The sources the page's 动态 stream merges, when it draws the stream's count (objectstack#28737). */
219+ timeline ?: { discussion : boolean ; activity : boolean ; fieldChanges : boolean } ;
213220} ) : RecordPageRequest {
214221 return {
215222 ...( plan . expand . length > 0 ? { expand : plan . expand } : { } ) ,
@@ -227,6 +234,7 @@ export function recordPageRequestOf(plan: {
227234 ...( plan . discussion ? { discussion : true } : { } ) ,
228235 ...( plan . activity !== undefined ? { activity : { top : plan . activity } } : { } ) ,
229236 ...( plan . attachments !== undefined ? { attachments : { top : plan . attachments } } : { } ) ,
237+ ...( plan . timeline ? { timeline : plan . timeline } : { } ) ,
230238 } ;
231239}
232240
@@ -290,21 +298,45 @@ export function recordPageComments(payload: Promise<RecordPagePayload | null>):
290298
291299/**
292300 * The payload's activity as the record feed's activity read answers it
293- * (`{ data }`): rejects with that read's refusal.
301+ * (`{ data }`), with how many rows the record holds (`total`), so the feed
302+ * knows whether it holds them all: rejects with that read's refusal.
294303 */
295- export function recordPageActivity ( payload : Promise < RecordPagePayload | null > ) : Promise < { data : Record < string , any > [ ] } > {
304+ export function recordPageActivity (
305+ payload : Promise < RecordPagePayload | null > ,
306+ ) : Promise < { data : Record < string , any > [ ] ; total : number } > {
296307 return payload . then ( ( page ) => {
297308 const part = page ?. activity ;
298- if ( ! page || ! part ) return { data : [ ] } ;
309+ if ( ! page || ! part ) return { data : [ ] , total : 0 } ;
299310 if ( isRefused ( part ) ) {
300311 const thrown = streamRefusal ( part . error , 'Activity refused' ) ;
301312 if ( thrown ) throw thrown ;
302- return { data : [ ] } ;
313+ return { data : [ ] , total : 0 } ;
303314 }
304- return { data : part . records ?? [ ] } ;
315+ const data = part . records ?? [ ] ;
316+ return { data, total : typeof part . total === 'number' ? part . total : data . length } ;
305317 } ) ;
306318}
307319
320+ /**
321+ * The 动态 stream's count as the payload answers it (objectstack#28737):
322+ * `total`, and how many of its entries are the comments the payload's
323+ * discussion carried (`comments`) — the comment half the feed holds whole and
324+ * keeps current through its own writes, so the page's count is
325+ * `total - comments + the comments it holds`. `null` when the payload carries
326+ * no count or a read behind it was refused: the feed's own refusal says so.
327+ */
328+ export function recordPageTimeline (
329+ payload : Promise < RecordPagePayload | null > ,
330+ ) : Promise < { total : number ; comments : number } | null > {
331+ return payload . then ( ( page ) => {
332+ const part = page ?. timeline ;
333+ if ( ! page || ! part || isRefused ( part ) ) return null ;
334+ const discussion = page . discussion ;
335+ const comments = discussion && ! isRefused ( discussion ) ? ( discussion . comments ?? [ ] ) . length : 0 ;
336+ return { total : part . total , comments } ;
337+ } , ( ) => null ) ;
338+ }
339+
308340/**
309341 * Hand each part of the payload to the reader that asks it. Call it before any
310342 * reader's effect runs (a layout effect of the page), so each reader joins its
0 commit comments