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
Conversation
src/matrix/room/Room.js
Outdated
@@ -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); |
There was a problem hiding this comment.
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)
87605b2
to
34f0db1
Compare
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>
68c7d44
to
2cae7c4
Compare
Signed-off-by: RMidhunSuresh <rmidhunsuresh@gmail.com>
Signed-off-by: RMidhunSuresh <rmidhunsuresh@gmail.com>
Signed-off-by: RMidhunSuresh <rmidhunsuresh@gmail.com>
There was a problem hiding this 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
did you test btw that this updates the member panel role when changing the power level? |
Signed-off-by: RMidhunSuresh <rmidhunsuresh@gmail.com>
No description provided.