File tree Expand file tree Collapse file tree 2 files changed +13
-1
lines changed
crates/matrix-sdk-ui/src/timeline Expand file tree Collapse file tree 2 files changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -1764,6 +1764,18 @@ impl TimelineController {
17641764 state. items . all_remote_events ( ) . last ( ) . map ( |event_meta| & event_meta. event_id ) . cloned ( )
17651765 }
17661766
1767+ /// Returns the latest event identifier from the visible timeline items.
1768+ pub ( crate ) async fn latest_visible_event_id ( & self ) -> Option < OwnedEventId > {
1769+ let state = self . state . read ( ) . await ;
1770+ state
1771+ . items
1772+ . iter ( )
1773+ . filter ( |item| item. is_event ( ) && !item. is_local_echo ( ) )
1774+ . last ( )
1775+ . and_then ( |event_meta| event_meta. as_event ( ) . unwrap ( ) . event_id ( ) )
1776+ . map ( ToOwned :: to_owned)
1777+ }
1778+
17671779 #[ instrument( skip( self ) , fields( room_id = ?self . room( ) . room_id( ) ) ) ]
17681780 pub ( super ) async fn retry_event_decryption ( & self , session_ids : Option < BTreeSet < String > > ) {
17691781 self . retry_event_decryption_inner ( session_ids) . await
Original file line number Diff line number Diff line change @@ -796,7 +796,7 @@ impl Timeline {
796796 /// Returns a boolean indicating if it sent the receipt or not.
797797 #[ instrument( skip( self ) , fields( room_id = ?self . room( ) . room_id( ) ) ) ]
798798 pub async fn mark_as_read ( & self , receipt_type : ReceiptType ) -> Result < bool > {
799- if let Some ( event_id) = self . controller . latest_event_id ( ) . await {
799+ if let Some ( event_id) = self . controller . latest_visible_event_id ( ) . await {
800800 self . send_single_receipt ( receipt_type, event_id) . await
801801 } else {
802802 trace ! ( "can't mark room as read because there's no latest event id" ) ;
You can’t perform that action at this time.
0 commit comments