adjust to new ObservableMap api
This commit is contained in:
parent
4d28448920
commit
db53db7007
2 changed files with 3 additions and 4 deletions
|
@ -17,7 +17,7 @@ export default class Room extends EventEmitter {
|
||||||
this._persister.persistSync(roomResponse, txn);
|
this._persister.persistSync(roomResponse, txn);
|
||||||
if (changed) {
|
if (changed) {
|
||||||
this.emit("change");
|
this.emit("change");
|
||||||
(this._emitCollectionChange)();
|
(this._emitCollectionChange)(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,8 +5,8 @@ export default class Session {
|
||||||
constructor(storage) {
|
constructor(storage) {
|
||||||
this._storage = storage;
|
this._storage = storage;
|
||||||
this._session = null;
|
this._session = null;
|
||||||
// use Map here?
|
|
||||||
this._rooms = new ObservableMap();
|
this._rooms = new ObservableMap();
|
||||||
|
this._roomUpdateCallback = (room, params) => this._rooms.update(room.id, params);
|
||||||
}
|
}
|
||||||
// should be called before load
|
// should be called before load
|
||||||
// loginData has device_id, user_id, home_server, access_token
|
// loginData has device_id, user_id, home_server, access_token
|
||||||
|
@ -47,8 +47,7 @@ export default class Session {
|
||||||
}
|
}
|
||||||
|
|
||||||
createRoom(roomId) {
|
createRoom(roomId) {
|
||||||
const updateCallback = (params) => this._rooms.update(roomId, params);
|
const room = new Room(roomId, this._storage, this._roomUpdateCallback);
|
||||||
const room = new Room(roomId, this._storage, updateCallback);
|
|
||||||
this._rooms.add(roomId, room);
|
this._rooms.add(roomId, room);
|
||||||
return room;
|
return room;
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue