Modify the group store to include group rooms
and modify components to use this new part of the store such that feedback can be given when adding or removing a room from the room list.
This commit is contained in:
parent
2ba0a801c4
commit
917957c1dc
5 changed files with 68 additions and 45 deletions
|
@ -26,7 +26,9 @@ export default class GroupStore extends EventEmitter {
|
|||
this.groupId = groupId;
|
||||
this._matrixClient = matrixClient;
|
||||
this._summary = {};
|
||||
this._rooms = [];
|
||||
this._fetchSummary();
|
||||
this._fetchRooms();
|
||||
}
|
||||
|
||||
_fetchSummary() {
|
||||
|
@ -38,6 +40,15 @@ export default class GroupStore extends EventEmitter {
|
|||
});
|
||||
}
|
||||
|
||||
_fetchRooms() {
|
||||
this._matrixClient.getGroupRooms(this.groupId).then((resp) => {
|
||||
this._rooms = resp.chunk;
|
||||
this._notifyListeners();
|
||||
}).catch((err) => {
|
||||
this.emit('error', err);
|
||||
});
|
||||
}
|
||||
|
||||
_notifyListeners() {
|
||||
this.emit('update');
|
||||
}
|
||||
|
@ -46,9 +57,22 @@ export default class GroupStore extends EventEmitter {
|
|||
return this._summary;
|
||||
}
|
||||
|
||||
getGroupRooms() {
|
||||
return this._rooms;
|
||||
}
|
||||
|
||||
addRoomToGroup(roomId) {
|
||||
return this._matrixClient
|
||||
.addRoomToGroup(this.groupId, roomId);
|
||||
.addRoomToGroup(this.groupId, roomId)
|
||||
.then(this._fetchRooms.bind(this));
|
||||
}
|
||||
|
||||
removeRoomFromGroup(roomId) {
|
||||
return this._matrixClient
|
||||
.removeRoomFromGroup(this.groupId, roomId)
|
||||
// Room might be in the summary, refresh just in case
|
||||
.then(this._fetchSummary.bind(this))
|
||||
.then(this._fetchRooms.bind(this));
|
||||
}
|
||||
|
||||
addRoomToGroupSummary(roomId, categoryId) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue