Factor-out GroupStore and create GroupStoreCache

In order to provide feedback when adding a room to a group, the group summarry store needs to be extended to store the list of rooms in a group. This commit is the first step required.

The next step is to get the GroupRoomList listening to updates from GroupStore and expose the list of rooms from GroupStore.

(We're running out of words to describe the hierachy of things that store things)
This commit is contained in:
Luke Barnard 2017-10-04 16:56:35 +01:00
parent 6875005e30
commit 4017fa7f1d
4 changed files with 73 additions and 29 deletions

View file

@ -19,6 +19,7 @@ import sdk from './';
import MultiInviter from './utils/MultiInviter';
import { _t } from './languageHandler';
import MatrixClientPeg from './MatrixClientPeg';
import GroupStoreCache from './stores/GroupStoreCache';
export function showGroupInviteDialog(groupId) {
const AddressPickerDialog = sdk.getComponent("dialogs.AddressPickerDialog");
@ -86,10 +87,11 @@ function _onGroupInviteFinished(groupId, addrs) {
}
function _onGroupAddRoomFinished(groupId, addrs) {
const groupStore = GroupStoreCache.getGroupStore(MatrixClientPeg.get(), groupId);
const errorList = [];
return Promise.all(addrs.map((addr) => {
return MatrixClientPeg.get()
.addRoomToGroup(groupId, addr.address)
return groupStore
.addRoomToGroup(addr.address)
.catch(() => { errorList.push(addr.address); })
.reflect();
})).then(() => {