Skip to content

Commit

Permalink
Fix get_dialogs could fail when count % chunk_size = 0
Browse files Browse the repository at this point in the history
Closes #3971.
  • Loading branch information
Lonami committed Nov 9, 2022
1 parent fb43f63 commit 2c85ffe
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion telethon/client/dialogs.py
Expand Up @@ -91,8 +91,9 @@ async def _load_next_chunk(self):
cd.entity, 'migrated_to', None) is None:
self.buffer.append(cd)

if len(r.dialogs) < self.request.limit\
if not self.buffer or len(r.dialogs) < self.request.limit\
or not isinstance(r, types.messages.DialogsSlice):
# Buffer being empty means all returned dialogs were skipped (due to offsets).
# Less than we requested means we reached the end, or
# we didn't get a DialogsSlice which means we got all.
return True
Expand Down

0 comments on commit 2c85ffe

Please sign in to comment.