From c5bf83eb86d6b1287a1b92253d76a14f99ad7b22 Mon Sep 17 00:00:00 2001 From: Lonami Exo Date: Mon, 23 May 2022 13:52:32 +0200 Subject: [PATCH] Remove unnecessary workaround when updating local pts --- telethon/_updates/messagebox.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/telethon/_updates/messagebox.py b/telethon/_updates/messagebox.py index 2e4fed91..21124cdd 100644 --- a/telethon/_updates/messagebox.py +++ b/telethon/_updates/messagebox.py @@ -485,17 +485,18 @@ class MessageBox: # `local_pts` must be the one before the server pts. local_pts = pts.pts - pts.pts_count - # For example, when we're in a channel, we immediately receive: + # In a channel, we may immediately receive: # * ReadChannelInbox (pts = X) # * NewChannelMessage (pts = X, pts_count = 1) # - # Notice how both `pts` are the same. If we stored the one from the first, then the second one would - # be considered "already handled" and ignored, which is not desirable. Instead, advance local `pts` - # by `pts_count` (which is 0 for updates not directly related to messages, like reading inbox). + # Notice how both `pts` are the same. The first one however would've triggered a gap + # because `local_pts` + `pts_count` of 0 would be less than `remote_pts`. So there is + # no risk by setting the `local_pts` to match the `remote_pts` here of missing the new + # message. if pts.entry in self.map: - self.map[pts.entry].pts = local_pts + pts.pts_count + self.map[pts.entry].pts = pts.pts else: - self.map[pts.entry] = State(pts=local_pts + pts.pts_count, deadline=next_updates_deadline()) + self.map[pts.entry] = State(pts=pts.pts, deadline=next_updates_deadline()) return update