diff --git a/src/matrix/Session.js b/src/matrix/Session.js index b18898bf..8eb0efbf 100644 --- a/src/matrix/Session.js +++ b/src/matrix/Session.js @@ -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([]); + } } }; }, diff --git a/src/matrix/room/Invite.js b/src/matrix/room/Invite.js index f71344cd..56304cfd 100644 --- a/src/matrix/room/Invite.js +++ b/src/matrix/room/Invite.js @@ -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);