From b8dca58f4f239edfc987ff472a6ce8cd3ece8872 Mon Sep 17 00:00:00 2001 From: Luke Barnard Date: Mon, 25 Sep 2017 10:02:13 +0100 Subject: [PATCH] Pass matrixClient as an argument to GSS constructor --- src/components/structures/GroupView.js | 4 +++- src/stores/GroupSummaryStore.js | 14 +++++++------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/components/structures/GroupView.js b/src/components/structures/GroupView.js index d3eb97180a..77034c3594 100644 --- a/src/components/structures/GroupView.js +++ b/src/components/structures/GroupView.js @@ -430,7 +430,9 @@ export default React.createClass({ }, _loadGroupFromServer: function(groupId) { - this._groupSummaryStore = new GroupSummaryStore(this.props.groupId); + this._groupSummaryStore = new GroupSummaryStore( + MatrixClientPeg.get(), this.props.groupId, + ); this._groupSummaryStore.on('update', () => { this.setState({ summary: this._groupSummaryStore.getSummary(), diff --git a/src/stores/GroupSummaryStore.js b/src/stores/GroupSummaryStore.js index a26f0f2d61..170a1ec11e 100644 --- a/src/stores/GroupSummaryStore.js +++ b/src/stores/GroupSummaryStore.js @@ -15,21 +15,21 @@ limitations under the License. */ import EventEmitter from 'events'; -import MatrixClientPeg from '../MatrixClientPeg'; /** * Stores the group summary for a room and provides an API to change it */ export default class GroupSummaryStore extends EventEmitter { - constructor(groupId) { + constructor(matrixClient, groupId) { super(); this._groupId = groupId; + this._matrixClient = matrixClient; this._summary = {}; this._fetchSummary(); } _fetchSummary() { - MatrixClientPeg.get().getGroupSummary(this._groupId).then((resp) => { + this._matrixClient.getGroupSummary(this._groupId).then((resp) => { this._summary = resp; this._notifyListeners(); }).catch((err) => { @@ -46,25 +46,25 @@ export default class GroupSummaryStore extends EventEmitter { } addRoomToGroupSummary(roomId, categoryId) { - return MatrixClientPeg.get() + return this._matrixClient .addRoomToGroupSummary(this._groupId, roomId, categoryId) .then(this._fetchSummary.bind(this)); } addUserToGroupSummary(userId, roleId) { - return MatrixClientPeg.get() + return this._matrixClient .addUserToGroupSummary(this._groupId, userId, roleId) .then(this._fetchSummary.bind(this)); } removeRoomFromGroupSummary(roomId) { - return MatrixClientPeg.get() + return this._matrixClient .removeRoomFromGroupSummary(this._groupId, roomId) .then(this._fetchSummary.bind(this)); } removeUserFromGroupSummary(userId) { - return MatrixClientPeg.get() + return this._matrixClient .removeUserFromGroupSummary(this._groupId, userId) .then(this._fetchSummary.bind(this)); }