@@ -1062,8 +1062,10 @@ impl<P: RoomDataProvider> TimelineController<P> {
1062
1062
decryptor : impl Decryptor ,
1063
1063
session_ids : Option < BTreeSet < String > > ,
1064
1064
) {
1065
- let mut state = self . state . clone ( ) . write_owned ( ) . await ;
1065
+ let state = self . state . clone ( ) . write_owned ( ) . await ;
1066
1066
1067
+ // We should retry an event if its session is included in the list, or the list
1068
+ // is None.
1067
1069
let should_retry = move |session_id : & str | {
1068
1070
if let Some ( session_ids) = & session_ids {
1069
1071
session_ids. contains ( session_id)
@@ -1072,8 +1074,27 @@ impl<P: RoomDataProvider> TimelineController<P> {
1072
1074
}
1073
1075
} ;
1074
1076
1077
+ // Find which messages need retrying
1075
1078
let retry_indices = event_indices_to_retry_decryption ( & state, & should_retry) ;
1076
1079
1080
+ // Retry decrypting
1081
+ self . retry_event_decryption_by_index ( state, retry_indices, should_retry, decryptor) . await ;
1082
+ }
1083
+
1084
+ /// Retry decryption of the supplied events, which are expected to be UTDs.
1085
+ ///
1086
+ /// `state` is the [`TimelineState`] state of the timeline.
1087
+ /// `retry_indices` contains the indices of events to try within the
1088
+ /// `state.items` `should_retry` checks that a session is included in
1089
+ /// the list of updated sessions. `decryptor` does the actual work of
1090
+ /// decrypting events.
1091
+ async fn retry_event_decryption_by_index (
1092
+ & self ,
1093
+ mut state : tokio:: sync:: OwnedRwLockWriteGuard < TimelineState > ,
1094
+ retry_indices : Vec < usize > ,
1095
+ should_retry : impl Fn ( & str ) -> bool + Send + Sync + ' static ,
1096
+ decryptor : impl Decryptor ,
1097
+ ) {
1077
1098
if retry_indices. is_empty ( ) {
1078
1099
return ;
1079
1100
}
0 commit comments