Make use of AlbumHack for all albums

Closes #3916.

The new MessageBox system is not designed with "albums come in the
same updates container" in mind (in fact, there was a note about this).

This version was also not intended to be published to PyPi, but it is,
so a workaround must be made for events.Album to remain working.

In essence, AlbumHack will always be used even if it technically did not
need to be used previously. This will cause a small delay for those
updates, but it should not be a major issue.
This commit is contained in:
Lonami Exo 2022-09-14 16:53:56 +02:00
parent a66df977f7
commit 7d4424ac2b
2 changed files with 5 additions and 2 deletions

View File

@ -260,6 +260,7 @@ class UpdateMethods:
await self._dispatch_update(updates_to_dispatch.popleft()) await self._dispatch_update(updates_to_dispatch.popleft())
else: else:
while updates_to_dispatch: while updates_to_dispatch:
# TODO if _dispatch_update fails for whatever reason, it's not logged! this should be fixed
task = self.loop.create_task(self._dispatch_update(updates_to_dispatch.popleft())) task = self.loop.create_task(self._dispatch_update(updates_to_dispatch.popleft()))
self._event_handler_tasks.add(task) self._event_handler_tasks.add(task)
task.add_done_callback(lambda _: self._event_handler_tasks.discard(task)) task.add_done_callback(lambda _: self._event_handler_tasks.discard(task))

View File

@ -97,8 +97,10 @@ class Album(EventBuilder):
@classmethod @classmethod
def build(cls, update, others=None, self_id=None): def build(cls, update, others=None, self_id=None):
if not others: # TODO normally we'd only check updates if they come with other updates
return # We only care about albums which come inside the same Updates # but MessageBox is not designed for this so others will always be None.
# In essence we always rely on AlbumHack rather than returning early if not others.
others = [update]
if isinstance(update, if isinstance(update,
(types.UpdateNewMessage, types.UpdateNewChannelMessage)): (types.UpdateNewMessage, types.UpdateNewChannelMessage)):