forked from mystiq/hydrogen-web
Update powerlevels in afterSync
Signed-off-by: RMidhunSuresh <rmidhunsuresh@gmail.com>
This commit is contained in:
parent
40128c7ff6
commit
4ddc7c0683
1 changed files with 14 additions and 5 deletions
|
@ -174,7 +174,7 @@ export class Room extends BaseRoom {
|
||||||
if (Array.isArray(roomResponse.timeline?.events)) {
|
if (Array.isArray(roomResponse.timeline?.events)) {
|
||||||
removedPendingEvents = await this._sendQueue.removeRemoteEchos(roomResponse.timeline.events, txn, log);
|
removedPendingEvents = await this._sendQueue.removeRemoteEchos(roomResponse.timeline.events, txn, log);
|
||||||
}
|
}
|
||||||
this._updatePowerLevels(roomResponse);
|
const powerLevelsEvent = this._getPowerLevelsEvent(roomResponse);
|
||||||
return {
|
return {
|
||||||
summaryChanges,
|
summaryChanges,
|
||||||
roomEncryption,
|
roomEncryption,
|
||||||
|
@ -184,6 +184,7 @@ export class Room extends BaseRoom {
|
||||||
removedPendingEvents,
|
removedPendingEvents,
|
||||||
memberChanges,
|
memberChanges,
|
||||||
heroChanges,
|
heroChanges,
|
||||||
|
powerLevelsEvent,
|
||||||
shouldFlushKeyShares,
|
shouldFlushKeyShares,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -196,7 +197,7 @@ export class Room extends BaseRoom {
|
||||||
afterSync(changes, log) {
|
afterSync(changes, log) {
|
||||||
const {
|
const {
|
||||||
summaryChanges, newEntries, updatedEntries, newLiveKey,
|
summaryChanges, newEntries, updatedEntries, newLiveKey,
|
||||||
removedPendingEvents, memberChanges,
|
removedPendingEvents, memberChanges, powerLevelsEvent,
|
||||||
heroChanges, roomEncryption
|
heroChanges, roomEncryption
|
||||||
} = changes;
|
} = changes;
|
||||||
log.set("id", this.id);
|
log.set("id", this.id);
|
||||||
|
@ -238,6 +239,9 @@ export class Room extends BaseRoom {
|
||||||
emitChange = true;
|
emitChange = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (powerLevelsEvent) {
|
||||||
|
this._updatePowerLevels(powerLevelsEvent);
|
||||||
|
}
|
||||||
if (emitChange) {
|
if (emitChange) {
|
||||||
this._emitUpdate();
|
this._emitUpdate();
|
||||||
}
|
}
|
||||||
|
@ -264,9 +268,14 @@ export class Room extends BaseRoom {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_updatePowerLevels(roomResponse) {
|
_getPowerLevelsEvent(roomResponse) {
|
||||||
const powerLevelEvent = roomResponse.timeline.events.find(event => event.type === POWERLEVELS_EVENT_TYPE);
|
const isPowerlevelEvent = event => event.type === POWERLEVELS_EVENT_TYPE;
|
||||||
if (powerLevelEvent && this._powerLevels) {
|
const powerLevelEvent = roomResponse.state?.events.find(isPowerlevelEvent) ?? roomResponse.timeline?.events.find(isPowerlevelEvent);
|
||||||
|
return powerLevelEvent;
|
||||||
|
}
|
||||||
|
|
||||||
|
_updatePowerLevels(powerLevelEvent) {
|
||||||
|
if (this._powerLevels) {
|
||||||
const newPowerLevels = new PowerLevels({
|
const newPowerLevels = new PowerLevels({
|
||||||
powerLevelEvent,
|
powerLevelEvent,
|
||||||
ownUserId: this._user.id,
|
ownUserId: this._user.id,
|
||||||
|
|
Loading…
Reference in a new issue