@@ -136,7 +136,7 @@ use ruma::{
136
136
EventId , OwnedEventId , OwnedUserId , RoomId , UserId ,
137
137
} ;
138
138
use serde:: { Deserialize , Serialize } ;
139
- use tracing:: { debug, instrument, trace} ;
139
+ use tracing:: { debug, instrument, trace, warn } ;
140
140
141
141
#[ derive( Clone , Debug , Serialize , Deserialize , PartialEq ) ]
142
142
struct LatestReadReceipt {
@@ -332,24 +332,27 @@ impl ReceiptSelector {
332
332
if event_pos >= * best_pos {
333
333
* best_pos = event_pos;
334
334
self . latest_event_with_receipt = Some ( event_id. to_owned ( ) ) ;
335
- trace ! ( "saving better" ) ;
335
+ debug ! ( "saving better" ) ;
336
+ } else {
337
+ trace ! ( "not better, keeping previous" ) ;
336
338
}
337
339
} else {
338
340
// We didn't have a previous receipt, this is the first one we
339
341
// store: remember it.
340
342
self . latest_event_pos = Some ( event_pos) ;
341
343
self . latest_event_with_receipt = Some ( event_id. to_owned ( ) ) ;
342
- trace ! ( "saving for the first time" ) ;
344
+ debug ! ( "saving for the first time" ) ;
343
345
}
344
346
}
345
347
346
348
/// Try to match pending receipts against new events.
349
+ #[ instrument( skip_all) ]
347
350
fn handle_pending_receipts ( & mut self , pending : & mut RingBuffer < OwnedEventId > ) {
348
351
// Try to match stashed receipts against the new events.
349
- trace ! ( "handle_pending_receipts" ) ;
350
352
pending. retain ( |event_id| {
351
353
if let Some ( event_pos) = self . event_id_to_pos . get ( event_id) {
352
354
// Maybe select this read receipt as it might be better than the ones we had.
355
+ trace ! ( %event_id, "matching event against its stashed receipt" ) ;
353
356
self . try_select_later ( event_id, * event_pos) ;
354
357
355
358
// Remove this stashed read receipt from the pending list, as it's been
@@ -371,23 +374,25 @@ impl ReceiptSelector {
371
374
///
372
375
/// Returns any receipts (for the current user) that we could not match
373
376
/// against any event - these are "pending".
377
+ #[ instrument( skip_all) ]
374
378
fn handle_new_receipt (
375
379
& mut self ,
376
380
user_id : & UserId ,
377
381
receipt_event : & ReceiptEventContent ,
378
382
) -> Vec < OwnedEventId > {
379
- trace ! ( "handle_new_receipt" ) ;
380
383
let mut pending = Vec :: new ( ) ;
381
384
// Now consider new receipts.
382
385
for ( event_id, receipts) in & receipt_event. 0 {
383
386
for ty in [ ReceiptType :: Read , ReceiptType :: ReadPrivate ] {
384
387
if let Some ( receipt) = receipts. get ( & ty) . and_then ( |receipts| receipts. get ( user_id) )
385
388
{
386
389
if matches ! ( receipt. thread, ReceiptThread :: Main | ReceiptThread :: Unthreaded ) {
390
+ trace ! ( %event_id, "found new candidate" ) ;
387
391
if let Some ( event_pos) = self . event_id_to_pos . get ( event_id) {
388
392
self . try_select_later ( event_id, * event_pos) ;
389
393
} else {
390
394
// It's a new pending receipt.
395
+ trace ! ( %event_id, "stashed as pending" ) ;
391
396
pending. push ( event_id. clone ( ) ) ;
392
397
}
393
398
}
@@ -502,7 +507,7 @@ pub(crate) fn compute_unread_counts(
502
507
// safely from here.
503
508
read_receipts. find_and_process_events ( & event_id, user_id, all_events. iter ( ) ) ;
504
509
505
- trace ! ( ?read_receipts, "after finding a better receipt" ) ;
510
+ debug ! ( ?read_receipts, "after finding a better receipt" ) ;
506
511
return ;
507
512
}
508
513
@@ -517,15 +522,15 @@ pub(crate) fn compute_unread_counts(
517
522
read_receipts. process_event ( event, user_id) ;
518
523
}
519
524
520
- trace ! ( ?read_receipts, "no better receipt, {} new events" , new_events. len( ) ) ;
525
+ debug ! ( ?read_receipts, "no better receipt, {} new events" , new_events. len( ) ) ;
521
526
}
522
527
523
528
/// Is the event worth marking a room as unread?
524
529
fn marks_as_unread ( event : & Raw < AnySyncTimelineEvent > , user_id : & UserId ) -> bool {
525
530
let event = match event. deserialize ( ) {
526
531
Ok ( event) => event,
527
532
Err ( err) => {
528
- debug ! (
533
+ warn ! (
529
534
"couldn't deserialize event {:?}: {err}" ,
530
535
event. get_field:: <String >( "event_id" ) . ok( ) . flatten( )
531
536
) ;
@@ -601,7 +606,7 @@ fn marks_as_unread(event: &Raw<AnySyncTimelineEvent>, user_id: &UserId) -> bool
601
606
602
607
_ => {
603
608
// What I don't know about, I don't care about.
604
- debug ! ( "unhandled timeline event type: {}" , event. event_type( ) ) ;
609
+ warn ! ( "unhandled timeline event type: {}" , event. event_type( ) ) ;
605
610
false
606
611
}
607
612
}
0 commit comments