@@ -349,7 +349,8 @@ export class RoomListViewModel
349349 } ;
350350
351351 /**
352- * Find the first unread room positioned below the visible area of the list.
352+ * Find the first room with an unread-message notification (a count badge — the green or
353+ * red decoration, not just the unread-activity dot) positioned below the visible area.
353354 *
354355 * "Below the fold" is determined from the last visible index reported by the
355356 * virtualized list (see {@link updateVisibleRooms}). For a grouped list the
@@ -358,24 +359,27 @@ export class RoomListViewModel
358359 * compare against that index space.
359360 *
360361 * Collapsed sections render only their header (their rooms are removed from the
361- * displayed sections), so their unread rooms are not directly reachable. When a
362- * collapsed section's header is itself below the fold and the section contains
363- * unread rooms , we surface the header as the target so clicking the toast scrolls
364- * it into view (revealing the header's aggregated unread badge).
362+ * displayed sections), so their notifying rooms are not directly reachable. When a
363+ * collapsed section's header is itself below the fold and the section contains a
364+ * notifying room , we surface the header as the target so clicking the toast scrolls
365+ * it into view (revealing the header's aggregated notification badge).
365366 *
366- * @returns The next unread room below the fold, or undefined if there is none
367+ * @returns The next notifying room below the fold, or undefined if there is none
367368 * (or the view has not yet reported a visible range).
368369 */
369370 private firstUnreadRoomBelowFold ( ) : { room : Room ; index : number } | undefined {
370371 if ( this . foldIndex < 0 ) return undefined ;
371372
372- const isUnread = ( room : Room ) : boolean => RoomNotificationStateStore . instance . getRoomState ( room ) . isUnread ;
373+ // Only surface rooms showing a notification badge (a count/symbol — the green or red
374+ // decoration), not rooms with just the unread-activity dot.
375+ const hasNotification = ( room : Room ) : boolean =>
376+ RoomNotificationStateStore . instance . getRoomState ( room ) . hasUnreadCount ;
373377
374378 if ( this . snapshot . current . isFlatList ) {
375379 // Flat list: virtualized indices map 1:1 to rooms.
376380 const rooms = this . sections . flatMap ( ( section ) => section . rooms ) ;
377381 for ( let i = this . foldIndex + 1 ; i < rooms . length ; i ++ ) {
378- if ( isUnread ( rooms [ i ] ) ) return { room : rooms [ i ] , index : i } ;
382+ if ( hasNotification ( rooms [ i ] ) ) return { room : rooms [ i ] , index : i } ;
379383 }
380384 return undefined ;
381385 }
@@ -395,15 +399,15 @@ export class RoomListViewModel
395399 // Collapsed: rooms aren't rendered, so the header is the only entry. If it is
396400 // below the fold and hides an unread room, target the header itself.
397401 if ( entryIndex > this . foldIndex ) {
398- const unreadRoom = ( fullRoomsByTag . get ( section . tag ) ?? [ ] ) . find ( isUnread ) ;
399- if ( unreadRoom ) return { room : unreadRoom , index : entryIndex } ;
402+ const notifyingRoom = ( fullRoomsByTag . get ( section . tag ) ?? [ ] ) . find ( hasNotification ) ;
403+ if ( notifyingRoom ) return { room : notifyingRoom , index : entryIndex } ;
400404 }
401405 continue ;
402406 }
403407
404408 for ( const room of section . rooms ) {
405409 entryIndex ++ ; // this room's entry
406- if ( entryIndex > this . foldIndex && isUnread ( room ) ) return { room, index : entryIndex } ;
410+ if ( entryIndex > this . foldIndex && hasNotification ( room ) ) return { room, index : entryIndex } ;
407411 }
408412 }
409413 return undefined ;
0 commit comments