mirror of https://github.com/vector-im/riot-web
Merge remote-tracking branch 'origin/develop' into develop
commit
8cace59088
|
@ -407,6 +407,10 @@ export default React.createClass({
|
||||||
getInitialState: function() {
|
getInitialState: function() {
|
||||||
return {
|
return {
|
||||||
summary: null,
|
summary: null,
|
||||||
|
isGroupPublicised: null,
|
||||||
|
isUserPrivileged: null,
|
||||||
|
groupRooms: null,
|
||||||
|
groupRoomsLoading: null,
|
||||||
error: null,
|
error: null,
|
||||||
editing: false,
|
editing: false,
|
||||||
saving: false,
|
saving: false,
|
||||||
|
@ -458,8 +462,11 @@ export default React.createClass({
|
||||||
}
|
}
|
||||||
this.setState({
|
this.setState({
|
||||||
summary,
|
summary,
|
||||||
|
summaryLoading: !this._groupStore.isStateReady(GroupStore.STATE_KEY.Summary),
|
||||||
isGroupPublicised: this._groupStore.getGroupPublicity(),
|
isGroupPublicised: this._groupStore.getGroupPublicity(),
|
||||||
isUserPrivileged: this._groupStore.isUserPrivileged(),
|
isUserPrivileged: this._groupStore.isUserPrivileged(),
|
||||||
|
groupRooms: this._groupStore.getGroupRooms(),
|
||||||
|
groupRoomsLoading: !this._groupStore.isStateReady(GroupStore.STATE_KEY.GroupRooms),
|
||||||
isUserMember: this._groupStore.getGroupMembers().some(
|
isUserMember: this._groupStore.getGroupMembers().some(
|
||||||
(m) => m.userId === MatrixClientPeg.get().credentials.userId,
|
(m) => m.userId === MatrixClientPeg.get().credentials.userId,
|
||||||
),
|
),
|
||||||
|
@ -653,6 +660,7 @@ export default React.createClass({
|
||||||
const RoomDetailList = sdk.getComponent('rooms.RoomDetailList');
|
const RoomDetailList = sdk.getComponent('rooms.RoomDetailList');
|
||||||
const AccessibleButton = sdk.getComponent('elements.AccessibleButton');
|
const AccessibleButton = sdk.getComponent('elements.AccessibleButton');
|
||||||
const TintableSvg = sdk.getComponent('elements.TintableSvg');
|
const TintableSvg = sdk.getComponent('elements.TintableSvg');
|
||||||
|
const Spinner = sdk.getComponent('elements.Spinner');
|
||||||
|
|
||||||
const addRoomRow = this.state.editing ?
|
const addRoomRow = this.state.editing ?
|
||||||
(<AccessibleButton className="mx_GroupView_rooms_header_addRow"
|
(<AccessibleButton className="mx_GroupView_rooms_header_addRow"
|
||||||
|
@ -670,7 +678,10 @@ export default React.createClass({
|
||||||
<h3>{ _t('Rooms') }</h3>
|
<h3>{ _t('Rooms') }</h3>
|
||||||
{ addRoomRow }
|
{ addRoomRow }
|
||||||
</div>
|
</div>
|
||||||
<RoomDetailList rooms={this._groupStore.getGroupRooms()} />
|
{ this.state.groupRoomsLoading ?
|
||||||
|
<Spinner /> :
|
||||||
|
<RoomDetailList rooms={this.state.groupRooms} />
|
||||||
|
}
|
||||||
</div>;
|
</div>;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -866,7 +877,7 @@ export default React.createClass({
|
||||||
const Spinner = sdk.getComponent("elements.Spinner");
|
const Spinner = sdk.getComponent("elements.Spinner");
|
||||||
const TintableSvg = sdk.getComponent("elements.TintableSvg");
|
const TintableSvg = sdk.getComponent("elements.TintableSvg");
|
||||||
|
|
||||||
if (this.state.summary === null && this.state.error === null || this.state.saving) {
|
if (this.state.summaryLoading && this.state.error === null || this.state.saving) {
|
||||||
return <Spinner />;
|
return <Spinner />;
|
||||||
} else if (this.state.summary) {
|
} else if (this.state.summary) {
|
||||||
const summary = this.state.summary;
|
const summary = this.state.summary;
|
||||||
|
|
|
@ -23,12 +23,23 @@ import FlairStore from './FlairStore';
|
||||||
* other useful group APIs that may have an effect on the group summary.
|
* other useful group APIs that may have an effect on the group summary.
|
||||||
*/
|
*/
|
||||||
export default class GroupStore extends EventEmitter {
|
export default class GroupStore extends EventEmitter {
|
||||||
|
|
||||||
|
static STATE_KEY = {
|
||||||
|
GroupMembers: 'GroupMembers',
|
||||||
|
GroupInvitedMembers: 'GroupInvitedMembers',
|
||||||
|
Summary: 'Summary',
|
||||||
|
GroupRooms: 'GroupRooms',
|
||||||
|
};
|
||||||
|
|
||||||
constructor(matrixClient, groupId) {
|
constructor(matrixClient, groupId) {
|
||||||
super();
|
super();
|
||||||
this.groupId = groupId;
|
this.groupId = groupId;
|
||||||
this._matrixClient = matrixClient;
|
this._matrixClient = matrixClient;
|
||||||
this._summary = {};
|
this._summary = {};
|
||||||
this._rooms = [];
|
this._rooms = [];
|
||||||
|
this._members = [];
|
||||||
|
this._invitedMembers = [];
|
||||||
|
this._ready = {};
|
||||||
|
|
||||||
this.on('error', (err) => {
|
this.on('error', (err) => {
|
||||||
console.error(`GroupStore for ${this.groupId} encountered error`, err);
|
console.error(`GroupStore for ${this.groupId} encountered error`, err);
|
||||||
|
@ -40,6 +51,7 @@ export default class GroupStore extends EventEmitter {
|
||||||
this._members = result.chunk.map((apiMember) => {
|
this._members = result.chunk.map((apiMember) => {
|
||||||
return groupMemberFromApiObject(apiMember);
|
return groupMemberFromApiObject(apiMember);
|
||||||
});
|
});
|
||||||
|
this._ready[GroupStore.STATE_KEY.GroupMembers] = true;
|
||||||
this._notifyListeners();
|
this._notifyListeners();
|
||||||
}).catch((err) => {
|
}).catch((err) => {
|
||||||
console.error("Failed to get group member list: " + err);
|
console.error("Failed to get group member list: " + err);
|
||||||
|
@ -50,6 +62,7 @@ export default class GroupStore extends EventEmitter {
|
||||||
this._invitedMembers = result.chunk.map((apiMember) => {
|
this._invitedMembers = result.chunk.map((apiMember) => {
|
||||||
return groupMemberFromApiObject(apiMember);
|
return groupMemberFromApiObject(apiMember);
|
||||||
});
|
});
|
||||||
|
this._ready[GroupStore.STATE_KEY.GroupInvitedMembers] = true;
|
||||||
this._notifyListeners();
|
this._notifyListeners();
|
||||||
}).catch((err) => {
|
}).catch((err) => {
|
||||||
// Invited users not visible to non-members
|
// Invited users not visible to non-members
|
||||||
|
@ -64,6 +77,7 @@ export default class GroupStore extends EventEmitter {
|
||||||
_fetchSummary() {
|
_fetchSummary() {
|
||||||
this._matrixClient.getGroupSummary(this.groupId).then((resp) => {
|
this._matrixClient.getGroupSummary(this.groupId).then((resp) => {
|
||||||
this._summary = resp;
|
this._summary = resp;
|
||||||
|
this._ready[GroupStore.STATE_KEY.Summary] = true;
|
||||||
this._notifyListeners();
|
this._notifyListeners();
|
||||||
}).catch((err) => {
|
}).catch((err) => {
|
||||||
this.emit('error', err);
|
this.emit('error', err);
|
||||||
|
@ -75,6 +89,7 @@ export default class GroupStore extends EventEmitter {
|
||||||
this._rooms = resp.chunk.map((apiRoom) => {
|
this._rooms = resp.chunk.map((apiRoom) => {
|
||||||
return groupRoomFromApiObject(apiRoom);
|
return groupRoomFromApiObject(apiRoom);
|
||||||
});
|
});
|
||||||
|
this._ready[GroupStore.STATE_KEY.GroupRooms] = true;
|
||||||
this._notifyListeners();
|
this._notifyListeners();
|
||||||
}).catch((err) => {
|
}).catch((err) => {
|
||||||
this.emit('error', err);
|
this.emit('error', err);
|
||||||
|
@ -87,6 +102,8 @@ export default class GroupStore extends EventEmitter {
|
||||||
|
|
||||||
registerListener(fn) {
|
registerListener(fn) {
|
||||||
this.on('update', fn);
|
this.on('update', fn);
|
||||||
|
// Call to set initial state (before fetching starts)
|
||||||
|
this.emit('update');
|
||||||
this._fetchSummary();
|
this._fetchSummary();
|
||||||
this._fetchRooms();
|
this._fetchRooms();
|
||||||
this._fetchMembers();
|
this._fetchMembers();
|
||||||
|
@ -96,6 +113,10 @@ export default class GroupStore extends EventEmitter {
|
||||||
this.removeListener('update', fn);
|
this.removeListener('update', fn);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
isStateReady(id) {
|
||||||
|
return this._ready[id];
|
||||||
|
}
|
||||||
|
|
||||||
getSummary() {
|
getSummary() {
|
||||||
return this._summary;
|
return this._summary;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue