Skip to content

Commit ed516f5

Browse files
committed
Apply seq if all updates were applied
Instead of only checking if *any* update *with pts* was applied.
1 parent 4a440b0 commit ed516f5

File tree

1 file changed

+11
-18
lines changed
  • lib/grammers-session/src/message_box

1 file changed

+11
-18
lines changed

lib/grammers-session/src/message_box/mod.rs

+11-18
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,6 @@ impl MessageBox {
484484
// It mutates the local pts state, remembers possible gaps, builds a set of entries for
485485
// which the deadlines should be reset, and determines whether any local pts was changed
486486
// so that the seq can be updated too (which could otherwise have been done earlier).
487-
let mut any_pts_applied = false;
488487
let mut reset_deadlines_for = mem::take(&mut self.tmp_entries);
489488
for update in updates {
490489
let (entry, update) = self.apply_pts_info(update);
@@ -496,29 +495,12 @@ impl MessageBox {
496495
}
497496
if let Some(update) = update {
498497
result.push(update);
499-
any_pts_applied |= entry.is_some();
500498
}
501499
}
502500
self.reset_deadlines(&reset_deadlines_for, next_updates_deadline());
503501
reset_deadlines_for.clear();
504502
self.tmp_entries = reset_deadlines_for;
505503

506-
// > If the updates were applied, local *Updates* state must be updated
507-
// > with `seq` (unless it's 0) and `date` from the constructor.
508-
//
509-
// By "were applied", we assume it means "some other pts was applied".
510-
// Updates which can be applied in any order, such as `UpdateChat`,
511-
// should not cause `seq` to be updated (or upcoming updates such as
512-
// `UpdateChatParticipant` could be missed).
513-
if any_pts_applied {
514-
if date != NO_DATE {
515-
self.date = date;
516-
}
517-
if seq != NO_SEQ {
518-
self.seq = seq;
519-
}
520-
}
521-
522504
if !self.possible_gaps.is_empty() {
523505
// For each update in possible gaps, see if the gap has been resolved already.
524506
let keys = self.possible_gaps.keys().copied().collect::<Vec<_>>();
@@ -546,6 +528,17 @@ impl MessageBox {
546528
}
547529
}
548530

531+
if !result.is_empty() && self.possible_gaps.is_empty() {
532+
// > If the updates were applied, local *Updates* state must be updated
533+
// > with `seq` (unless it's 0) and `date` from the constructor.
534+
if date != NO_DATE {
535+
self.date = date;
536+
}
537+
if seq != NO_SEQ {
538+
self.seq = seq;
539+
}
540+
}
541+
549542
Ok((result, users, chats))
550543
}
551544

0 commit comments

Comments
 (0)