Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Member Panel - PR 3 - Update powerlevels from state event #432

Merged
merged 8 commits into from Aug 6, 2021

Conversation

MidhunSureshR
Copy link
Contributor

No description provided.

@@ -173,6 +174,7 @@ export class Room extends BaseRoom {
if (Array.isArray(roomResponse.timeline?.events)) {
removedPendingEvents = await this._sendQueue.removeRemoteEchos(roomResponse.timeline.events, txn, log);
}
this._updatePowerLevels(roomResponse);
Copy link
Contributor

Choose a reason for hiding this comment

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

This (e.g. updating in-memory data) should happen in afterSync, rather than writeSync, which is only about trying to persist the room response and returning data to incrementally update in-memory data with in afterSync. This is so that in-memory data structures are not altered until the storage transaction has successfully committed, so in case something goes wrong, we can safely retry without having data being out of sync between storage and in-memory. afterSync receives the return value from writeSync for this purpose. So here you'll actually want to return the new state events from the room response, and then call _updatePowerLevels with it in afterSync.

To find out about new state events, you'll need to look both at roomResponse.state.events (any state events since the last sync and the beginning of the returned timeline chunk in this sync response) and roomResponse.timeline.events (where state events are mixed with non-state events, and you can just filter events that have a state_key)

@MidhunSureshR MidhunSureshR changed the title [WIP] - Member Panel - Update powerlevels from state event Member Panel - PR 3 - Update powerlevels from state event Aug 5, 2021
src/matrix/room/Room.js Outdated Show resolved Hide resolved
src/matrix/room/Room.js Outdated Show resolved Hide resolved
Signed-off-by: RMidhunSuresh <rmidhunsuresh@gmail.com>
Signed-off-by: RMidhunSuresh <rmidhunsuresh@gmail.com>
Signed-off-by: RMidhunSuresh <rmidhunsuresh@gmail.com>
Signed-off-by: RMidhunSuresh <rmidhunsuresh@gmail.com>
Signed-off-by: RMidhunSuresh <rmidhunsuresh@gmail.com>
Signed-off-by: RMidhunSuresh <rmidhunsuresh@gmail.com>
Signed-off-by: RMidhunSuresh <rmidhunsuresh@gmail.com>
Copy link
Contributor

@bwindels bwindels left a comment

Choose a reason for hiding this comment

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

looks great, just one small cleanup but basically ready to go

src/matrix/room/Room.js Outdated Show resolved Hide resolved
@bwindels
Copy link
Contributor

bwindels commented Aug 6, 2021

did you test btw that this updates the member panel role when changing the power level?

Signed-off-by: RMidhunSuresh <rmidhunsuresh@gmail.com>
@bwindels bwindels merged commit 7d9ccb9 into element-hq:master Aug 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants