stored summary is no longer passed in ctor but loaded in load method

This commit is contained in:
Bruno Windels 2019-02-04 22:30:10 +00:00
parent f58af883b8
commit 5703a034ca
2 changed files with 7 additions and 6 deletions

View File

@ -1,9 +1,9 @@
class Room {
constructor(roomId, storage, storedSummary) {
constructor(roomId, storage) {
this._roomId = roomId;
this._storage = storage;
this._summary = new RoomSummary(this._roomId, this._storage, storedSummary);
this._summary = new RoomSummary(this._roomId, this._storage);
}
async applyInitialSync(roomResponse, membership) {
@ -14,7 +14,7 @@ class Room {
}
async loadFromStorage() {
async load() {
}
}

View File

@ -4,9 +4,10 @@ function disambiguateMember(name, userId) {
return `${name} (${userId})`;
}
// could even split name calculation in a separate class
// as the summary will grow more
export class RoomSummary {
constructor(roomId, storage) {
this._storage = storage;
constructor(roomId) {
this._members = new SummaryMembers();
this._roomId = roomId;
this._inviteCount = 0;
@ -40,7 +41,7 @@ export class RoomSummary {
return changed;
}
async loadFromStorage() {
async load() {
const summary = await storage.getSummary(this._roomId);
this._roomId = summary.roomId;
this._inviteCount = summary.inviteCount;