Remove unnecessary workaround when updating local pts

This commit is contained in:
Lonami Exo 2022-05-23 13:52:32 +02:00
parent 5a1b9daf4c
commit c5bf83eb86

View File

@ -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