@@ -1291,8 +1291,9 @@ impl RoomScreen {
12911291 tl. content_drawn_since_last_update . remove ( changed_indices. clone ( ) ) ;
12921292 tl. profile_drawn_since_last_update . remove ( changed_indices. clone ( ) ) ;
12931293 }
1294- // Handles item_id changes whenever there is a backward pagination.
1295- if !is_append {
1294+ // Handle index changes and group updates based on the update type
1295+ if clear_cache {
1296+ // Clear cache indicates all indices changed (typically back pagination)
12961297 let old_len = tl. items . len ( ) ;
12971298 let new_len = new_items. len ( ) ;
12981299 let shift = new_len. saturating_sub ( old_len) as i32 ;
@@ -1301,7 +1302,15 @@ impl RoomScreen {
13011302 & mut tl. group_manager ,
13021303 ) ;
13031304 }
1305+
13041306 tl. items = new_items;
1307+
1308+ // Update small state groups based on changed indices
1309+ tl. group_manager . analyze_and_update_groups (
1310+ & tl. items ,
1311+ changed_indices. clone ( ) ,
1312+ clear_cache,
1313+ ) ;
13051314 done_loading = true ;
13061315 }
13071316 TimelineUpdate :: NewUnreadMessagesCount ( unread_messages_count) => {
@@ -4066,7 +4075,7 @@ fn populate_small_state_event(
40664075
40674076 let ( show, collapsible_button) = ( result. show , result. collapsible_button ) ;
40684077 // Only show the collapsible button on the first item of each group
4069- item. button ( ids ! ( collapsible_button ) )
4078+ item. view ( ids ! ( small_state_header . collapsible_button_container ) )
40704079 . set_visible ( cx, collapsible_button != small_state_group_manager:: CollapsibleButton :: None ) ;
40714080 let ( item, new_drawn_status) = event_content. populate_item_content (
40724081 cx,
0 commit comments