Skip to content

Commit c1d4b02

Browse files
committed
Change toast to target notifications only, not unread activity.
1 parent c71ae4a commit c1d4b02

4 files changed

Lines changed: 18 additions & 14 deletions

File tree

apps/web/src/viewmodels/room-list/RoomListViewModel.ts

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -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;

packages/shared-components/src/i18n/strings/en_EN.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@
185185
"home": "Space home",
186186
"space_settings": "Space settings"
187187
},
188-
"unread_activity": "You have unread activity"
188+
"unread_messages": "Unread messages"
189189
},
190190
"terms": {
191191
"tac_button": "Review terms and conditions"

packages/shared-components/src/room-list/RoomListView/UnreadActivityToast/UnreadActivityToast.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ describe("<UnreadActivityToast />", () => {
2424
it("calls onClick when the toast is clicked", async () => {
2525
const user = userEvent.setup();
2626
render(<Default />);
27-
await user.click(screen.getByRole("button", { name: "You have unread activity" }));
27+
await user.click(screen.getByRole("button", { name: "Unread messages" }));
2828
expect(Default.args.onClick).toHaveBeenCalled();
2929
});
3030
});

packages/shared-components/src/room-list/RoomListView/UnreadActivityToast/UnreadActivityToast.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export function UnreadActivityToast({ onClick }: Readonly<UnreadActivityToastPro
3535

3636
return (
3737
<Toast className={styles.toast} Icon={ArrowDownIcon} onClick={onClick}>
38-
{_t("room_list|unread_activity")}
38+
{_t("room_list|unread_messages")}
3939
</Toast>
4040
);
4141
}

0 commit comments

Comments
 (0)