forked from mystiq/hydrogen-web
restore invites when loading the session
This commit is contained in:
parent
5876e5200b
commit
ee98eaa640
2 changed files with 16 additions and 2 deletions
|
@ -258,6 +258,7 @@ export class Session {
|
|||
const txn = await this._storage.readTxn([
|
||||
this._storage.storeNames.session,
|
||||
this._storage.storeNames.roomSummary,
|
||||
this._storage.storeNames.invites,
|
||||
this._storage.storeNames.roomMembers,
|
||||
this._storage.storeNames.timelineEvents,
|
||||
this._storage.storeNames.timelineFragments,
|
||||
|
@ -289,6 +290,13 @@ export class Session {
|
|||
await log.wrap("room", log => room.load(summary, txn, log));
|
||||
this._rooms.add(room.id, room);
|
||||
}));
|
||||
// load invites
|
||||
const invites = await txn.invites.getAll();
|
||||
await Promise.all(invites.map(async inviteData => {
|
||||
const invite = this.createInvite(inviteData.roomId);
|
||||
log.wrap("invite", log => invite.load(inviteData, log));
|
||||
this._invites.add(invite.id, invite);
|
||||
}));
|
||||
}
|
||||
|
||||
dispose() {
|
||||
|
@ -583,6 +591,11 @@ export function tests() {
|
|||
getAll() {
|
||||
return Promise.resolve([]);
|
||||
}
|
||||
},
|
||||
invites: {
|
||||
getAll() {
|
||||
return Promise.resolve([]);
|
||||
}
|
||||
}
|
||||
};
|
||||
},
|
||||
|
|
|
@ -70,7 +70,8 @@ export class Invite extends EventEmitter {
|
|||
|
||||
}
|
||||
|
||||
load(inviteData) {
|
||||
load(inviteData, log) {
|
||||
log.set("id", this.id);
|
||||
this._inviteData = inviteData;
|
||||
this._inviter = inviteData.inviter ? new RoomMember(inviteData.inviter) : null;
|
||||
}
|
||||
|
@ -257,7 +258,7 @@ export function tests() {
|
|||
const txn = createStorage();
|
||||
await writeInvite.writeSync("invite", dmInviteFixture, txn, new NullLogItem());
|
||||
const invite = new Invite({roomId});
|
||||
invite.load(txn.invitesMap.get(roomId));
|
||||
invite.load(txn.invitesMap.get(roomId), new NullLogItem());
|
||||
assert.equal(invite.name, "Alice");
|
||||
assert.equal(invite.avatarUrl, aliceAvatarUrl);
|
||||
assert.equal(invite.timestamp, 1003);
|
||||
|
|
Loading…
Reference in a new issue