forked from mystiq/hydrogen-web
Set pl from room response
Signed-off-by: RMidhunSuresh <rmidhunsuresh@gmail.com>
This commit is contained in:
parent
b75760c437
commit
40128c7ff6
1 changed files with 14 additions and 0 deletions
|
@ -23,6 +23,7 @@ import {WrappedError} from "../error.js"
|
||||||
import {Heroes} from "./members/Heroes.js";
|
import {Heroes} from "./members/Heroes.js";
|
||||||
import {AttachmentUpload} from "./AttachmentUpload.js";
|
import {AttachmentUpload} from "./AttachmentUpload.js";
|
||||||
import {DecryptionSource} from "../e2ee/common.js";
|
import {DecryptionSource} from "../e2ee/common.js";
|
||||||
|
import {PowerLevels, EVENT_TYPE as POWERLEVELS_EVENT_TYPE } from "./timeline/PowerLevels.js";
|
||||||
|
|
||||||
const EVENT_ENCRYPTED_TYPE = "m.room.encrypted";
|
const EVENT_ENCRYPTED_TYPE = "m.room.encrypted";
|
||||||
|
|
||||||
|
@ -173,6 +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);
|
||||||
return {
|
return {
|
||||||
summaryChanges,
|
summaryChanges,
|
||||||
roomEncryption,
|
roomEncryption,
|
||||||
|
@ -262,6 +264,18 @@ export class Room extends BaseRoom {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_updatePowerLevels(roomResponse) {
|
||||||
|
const powerLevelEvent = roomResponse.timeline.events.find(event => event.type === POWERLEVELS_EVENT_TYPE);
|
||||||
|
if (powerLevelEvent && this._powerLevels) {
|
||||||
|
const newPowerLevels = new PowerLevels({
|
||||||
|
powerLevelEvent,
|
||||||
|
ownUserId: this._user.id,
|
||||||
|
membership: this.membership,
|
||||||
|
});
|
||||||
|
this._powerLevels.set(newPowerLevels);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
needsAfterSyncCompleted({shouldFlushKeyShares}) {
|
needsAfterSyncCompleted({shouldFlushKeyShares}) {
|
||||||
return shouldFlushKeyShares;
|
return shouldFlushKeyShares;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue