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

only dispatch an action for self-membership #2160

Merged
merged 2 commits into from
Sep 10, 2018

Conversation

bwindels
Copy link
Contributor

@bwindels bwindels commented Sep 7, 2018

as literally everything listens to the dispatcher, dispatching an action can be quite slow,
especially when only matched in one listener, and the rest all having to be called
to just say "no, thanks". This is especially the case for the RoomMember.membership
event being put on the dispatcher, as there can be thousands of these events
when the room members are loading.

Since the RoomMember.membership action is only used on one place,
and only for the syncing user, change it to just that and only dispatch
in that case. This saves 100-300ms when setting the OOB members in
a big room (7000k members)

Maybe later on we can back this by room.getMyMembership() and avoid the
listener even...

as everything listens to the dispatcher, dispatching an action can be quite slow,
especially when only matched in one listener, and the rest all having to be called
to just say "no, thanks". This is especially the case for the RoomMember.membership
event being put on the dispatcher, as there can be thousands of these events
when the room members are loading.

Since the RoomMember.membership action is only used on one place,
and only for the syncing user, change it to just that and only dispatch
in that case. This saves 100-300ms when setting the OOB members in
a big room (7000k members)

Maybe later on we can back this by room.getMyMembership() and avoid the
listener even...
@bwindels bwindels requested a review from a team September 7, 2018 17:58
Copy link
Member

@dbkr dbkr left a comment

Choose a reason for hiding this comment

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

otherwise lgtm

function createSelfRoomMembershipAction(matrixClient, membershipEvent, member, oldMembership) {
if (member.userId === matrixClient.getUserId()) {
return { action: 'MatrixActions.Room.selfMembership', member };
}
Copy link
Member

Choose a reason for hiding this comment

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

possibly a return null for clarity?

@bwindels bwindels merged commit ab931e0 into develop Sep 10, 2018
@bwindels bwindels deleted the bwindels/selfmembershipaction branch September 10, 2018 15:30
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.

2 participants