forked from mystiq/hydrogen-web
fall back to bare userid for local echo profile
This commit is contained in:
parent
521894f401
commit
863f659774
3 changed files with 14 additions and 3 deletions
|
@ -678,7 +678,7 @@ export class Room extends EventEmitter {
|
||||||
if (this._roomEncryption) {
|
if (this._roomEncryption) {
|
||||||
this._timeline.enableEncryption(this._decryptEntries.bind(this, DecryptionSource.Timeline));
|
this._timeline.enableEncryption(this._decryptEntries.bind(this, DecryptionSource.Timeline));
|
||||||
}
|
}
|
||||||
await this._timeline.load(this._user, log);
|
await this._timeline.load(this._user, this._summary.data.membership, log);
|
||||||
return this._timeline;
|
return this._timeline;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,6 +23,10 @@ export class RoomMember {
|
||||||
this._data = data;
|
this._data = data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static fromUserId(roomId, userId, membership) {
|
||||||
|
return new RoomMember({roomId, userId, membership});
|
||||||
|
}
|
||||||
|
|
||||||
static fromMemberEvent(roomId, memberEvent) {
|
static fromMemberEvent(roomId, memberEvent) {
|
||||||
const userId = memberEvent?.state_key;
|
const userId = memberEvent?.state_key;
|
||||||
if (typeof userId !== "string") {
|
if (typeof userId !== "string") {
|
||||||
|
|
|
@ -45,10 +45,17 @@ export class Timeline {
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @package */
|
/** @package */
|
||||||
async load(user, log) {
|
async load(user, membership, log) {
|
||||||
const txn = await this._storage.readTxn(this._timelineReader.readTxnStores.concat(this._storage.storeNames.roomMembers));
|
const txn = await this._storage.readTxn(this._timelineReader.readTxnStores.concat(this._storage.storeNames.roomMembers));
|
||||||
const memberData = await txn.roomMembers.get(this._roomId, user.id);
|
const memberData = await txn.roomMembers.get(this._roomId, user.id);
|
||||||
this._ownMember = new RoomMember(memberData);
|
if (memberData) {
|
||||||
|
this._ownMember = new RoomMember(memberData);
|
||||||
|
} else {
|
||||||
|
// this should never happen, as our own join into the room would have
|
||||||
|
// made us receive our own member event, but just to be on the safe side and not crash,
|
||||||
|
// fall back to bare user id
|
||||||
|
this._ownMember = RoomMember.fromUserId(this._roomId, user.id, membership);
|
||||||
|
}
|
||||||
// it should be fine to not update the local entries,
|
// it should be fine to not update the local entries,
|
||||||
// as they should only populate once the view subscribes to it
|
// as they should only populate once the view subscribes to it
|
||||||
// if they are populated already, the sender profile would be empty
|
// if they are populated already, the sender profile would be empty
|
||||||
|
|
Loading…
Reference in a new issue