@@ -288,33 +288,6 @@ impl ReadReceipts {
288288 timeline_items : & mut ObservableItemsTransaction < ' _ > ,
289289 at_end : bool ,
290290 ) -> IndexMap < OwnedUserId , Receipt > {
291- // We only need to compute receipts for the visible events that will show them.
292- if !timeline_items
293- . all_remote_events ( )
294- . iter ( )
295- . find ( |meta| meta. event_id == event_id)
296- . map ( |meta| meta. visible && meta. can_show_read_receipts )
297- . unwrap_or ( false )
298- {
299- return Default :: default ( ) ;
300- }
301-
302- let mut all_receipts = self . get_event_receipts ( event_id) . cloned ( ) . unwrap_or_default ( ) ;
303-
304- if at_end {
305- // No need to search for extra receipts, there are no events after.
306- trace ! (
307- "early return because @end, retrieved receipts: {}" ,
308- all_receipts. iter( ) . map( |( u, _) | u. as_str( ) ) . collect:: <Vec <_>>( ) . join( ", " )
309- ) ;
310- return all_receipts;
311- }
312-
313- trace ! (
314- "loaded receipts: {}" ,
315- all_receipts. iter( ) . map( |( u, _) | u. as_str( ) ) . collect:: <Vec <_>>( ) . join( ", " )
316- ) ;
317-
318291 // We are going to add receipts for hidden events to this item.
319292 //
320293 // However: since we may be inserting an event at a random position, the
@@ -330,13 +303,32 @@ impl ReadReceipts {
330303
331304 for meta in events_iter. by_ref ( ) {
332305 if meta. event_id == event_id {
333- break ;
306+ // We only need to compute receipts for the visible events that will show them.
307+ if !meta. visible || !meta. can_show_read_receipts {
308+ return Default :: default ( ) ;
309+ }
334310 }
335311 if let Some ( item_index) = meta. timeline_item_index {
336312 prev_event_and_item_index = Some ( ( meta. event_id . clone ( ) , item_index) ) ;
337313 }
338314 }
339315
316+ let mut all_receipts = self . get_event_receipts ( event_id) . cloned ( ) . unwrap_or_default ( ) ;
317+
318+ if at_end {
319+ // No need to search for extra receipts, there are no events after.
320+ trace ! (
321+ "early return because @end, retrieved receipts: {}" ,
322+ all_receipts. iter( ) . map( |( u, _) | u. as_str( ) ) . collect:: <Vec <_>>( ) . join( ", " )
323+ ) ;
324+ return all_receipts;
325+ }
326+
327+ trace ! (
328+ "loaded receipts: {}" ,
329+ all_receipts. iter( ) . map( |( u, _) | u. as_str( ) ) . collect:: <Vec <_>>( ) . join( ", " )
330+ ) ;
331+
340332 // Include receipts from all the following events that are hidden or can't show
341333 // read receipts.
342334 let mut hidden = Vec :: new ( ) ;
0 commit comments