@@ -43,6 +43,7 @@ use ruma::{
43
43
api:: client as api,
44
44
events:: {
45
45
ignored_user_list:: IgnoredUserListEvent ,
46
+ marked_unread:: MarkedUnreadEventContent ,
46
47
push_rules:: { PushRulesEvent , PushRulesEventContent } ,
47
48
room:: {
48
49
member:: { MembershipState , RoomMemberEventContent , SyncRoomMemberEvent } ,
@@ -683,6 +684,25 @@ impl BaseClient {
683
684
}
684
685
}
685
686
687
+ // Helper to update the unread marker for stable and unstable prefixes.
688
+ fn on_unread_marker (
689
+ room_id : & RoomId ,
690
+ content : & MarkedUnreadEventContent ,
691
+ room_info : & mut RoomInfo ,
692
+ room_info_notable_updates : & mut BTreeMap < OwnedRoomId , RoomInfoNotableUpdateReasons > ,
693
+ ) {
694
+ if room_info. base_info . is_marked_unread != content. unread {
695
+ // Notify the room list about a manual read marker change if the
696
+ // value's changed.
697
+ room_info_notable_updates
698
+ . entry ( room_id. to_owned ( ) )
699
+ . or_default ( )
700
+ . insert ( RoomInfoNotableUpdateReasons :: UNREAD_MARKER ) ;
701
+ }
702
+
703
+ room_info. base_info . is_marked_unread = content. unread ;
704
+ }
705
+
686
706
// Handle new events.
687
707
for raw_event in events {
688
708
match raw_event. deserialize ( ) {
@@ -692,30 +712,22 @@ impl BaseClient {
692
712
match event {
693
713
AnyRoomAccountDataEvent :: MarkedUnread ( event) => {
694
714
on_room_info ( room_id, changes, self , |room_info| {
695
- if room_info. base_info . is_marked_unread != event. content . unread {
696
- // Notify the room list about a manual read marker change if the
697
- // value's changed.
698
- room_info_notable_updates
699
- . entry ( room_id. to_owned ( ) )
700
- . or_default ( )
701
- . insert ( RoomInfoNotableUpdateReasons :: UNREAD_MARKER ) ;
702
- }
703
-
704
- room_info. base_info . is_marked_unread = event. content . unread ;
715
+ on_unread_marker (
716
+ room_id,
717
+ & event. content ,
718
+ room_info,
719
+ room_info_notable_updates,
720
+ ) ;
705
721
} ) ;
706
722
}
707
723
AnyRoomAccountDataEvent :: UnstableMarkedUnread ( event) => {
708
724
on_room_info ( room_id, changes, self , |room_info| {
709
- if room_info. base_info . is_marked_unread != event. content . unread {
710
- // Notify the room list about a manual read marker change if the
711
- // value's changed.
712
- room_info_notable_updates
713
- . entry ( room_id. to_owned ( ) )
714
- . or_default ( )
715
- . insert ( RoomInfoNotableUpdateReasons :: UNREAD_MARKER ) ;
716
- }
717
-
718
- room_info. base_info . is_marked_unread = event. content . unread ;
725
+ on_unread_marker (
726
+ room_id,
727
+ & event. content . 0 ,
728
+ room_info,
729
+ room_info_notable_updates,
730
+ ) ;
719
731
} ) ;
720
732
}
721
733
AnyRoomAccountDataEvent :: Tag ( event) => {
0 commit comments