File tree Expand file tree Collapse file tree
packages/client-runtime/src/state Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -122,6 +122,12 @@ it("keeps a mark-unread on a read thread reopened within the open dedupe window"
122122 t . update ( { lastVisitedAt : at ( 8 ) } ) ;
123123 vi . advanceTimersByTime ( VISIT_DISPATCH_THROTTLE_MS ) ;
124124 expect ( t . visits ) . toEqual ( [ ] ) ;
125+
126+ // An authoritative snapshot can briefly replace the row with an older one.
127+ t . update ( { updatedAt : at ( 5 ) , lastVisitedAt : at ( 5 ) , latestRun : { completedAt : at ( 4 ) } } ) ;
128+ t . update ( { updatedAt : at ( 10 ) , lastVisitedAt : at ( 8 ) , latestRun : { completedAt : at ( 9 ) } } ) ;
129+ vi . advanceTimersByTime ( VISIT_DISPATCH_THROTTLE_MS ) ;
130+ expect ( t . visits ) . toEqual ( [ ] ) ;
125131} ) ;
126132
127133it ( "keeps mark unread sticky after an expired wake is retired" , ( ) => {
Original file line number Diff line number Diff line change @@ -116,7 +116,8 @@ export function createThreadVisitTracker(options: ThreadVisitTrackerOptions) {
116116 const lastVisitedAtMs = shell . lastVisitedAt ? Date . parse ( shell . lastVisitedAt ) : NaN ;
117117 if ( ! Number . isNaN ( lastVisitedAtMs ) && lastVisitedAtMs >= updatedAtMs ) {
118118 // Already seen, so a later mark-unread stays sticky even when no open was sent.
119- lastDispatchedUpdatedAt = visitedAt ;
119+ if ( lastDispatchedUpdatedAt === null || Date . parse ( lastDispatchedUpdatedAt ) < updatedAtMs )
120+ lastDispatchedUpdatedAt = visitedAt ;
120121 return ;
121122 }
122123 if ( lastDispatchedUpdatedAt !== null && Date . parse ( lastDispatchedUpdatedAt ) >= updatedAtMs )
You can’t perform that action at this time.
0 commit comments