Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Refactor the code that sends state events into new rooms #13291

Closed
wants to merge 5 commits into from

Conversation

anoadragon453
Copy link
Member

@anoadragon453 anoadragon453 commented Jul 15, 2022

A myriad of changes to the _send_events_for_new_room method, which calculates and sends the state events for a new room, given the room's preset and some other argument values.

This is split out from ongoing configurable room default/custom room presets work.

Recommended to review commit-by-commit, explanations for changes in commit descriptions.

This is still a draft for now while I build on top of it locally.

@anoadragon453 anoadragon453 force-pushed the anoa/create_room_cleanup branch from d54dc47 to f17677e Compare July 15, 2022 14:17
# Send each event in order of its insertion into the dictionary
for (event_type, state_key), content in state_to_send.items():
await send(etype=event_type, state_key=state_key, content=content)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're relying on dict being ordered (as defined in the language spec since Python 3.7). I assume this is fine to do?

@anoadragon453 anoadragon453 force-pushed the anoa/create_room_cleanup branch 2 times, most recently from d3cfd64 to cb93959 Compare August 9, 2022 09:37
@anoadragon453 anoadragon453 force-pushed the anoa/create_room_cleanup branch from cb93959 to a3d07fd Compare August 15, 2022 13:13
Instead of sending state events as we go, we instead calculate all state
events to send and store them in a dict (ordered since Python 3.7) and
then send them all at once in the end.

This has no performance benefit whatsoever, but I find this clearer to
reason about. My personal use case is eventually placing another layer
of "custom room preset" state on top, which would be easier to do with a
state map, instead of the previous code which sent state into the room
as it went along.

If we do eventually send all new room state simultaneously to speed up
local room creation, I believe this would be an easier starting point.
@anoadragon453 anoadragon453 force-pushed the anoa/create_room_cleanup branch from a3d07fd to eab9d34 Compare August 15, 2022 16:44
@anoadragon453
Copy link
Member Author

Superseded by changes in #13487.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant