Use constants instead of string literals
This commit is contained in:
parent
5bfed67463
commit
16dca08b77
2 changed files with 14 additions and 6 deletions
|
@ -462,11 +462,11 @@ export default React.createClass({
|
||||||
}
|
}
|
||||||
this.setState({
|
this.setState({
|
||||||
summary,
|
summary,
|
||||||
summaryLoading: !this._groupStore.isStateReady('GroupStore.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(),
|
groupRooms: this._groupStore.getGroupRooms(),
|
||||||
groupRoomsLoading: !this._groupStore.isStateReady('GroupStore.GroupRooms'),
|
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,
|
||||||
),
|
),
|
||||||
|
|
|
@ -23,6 +23,14 @@ 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;
|
||||||
|
@ -43,7 +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.GroupMembers'] = true;
|
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);
|
||||||
|
@ -54,7 +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.GroupInvitedMembers'] = true;
|
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
|
||||||
|
@ -69,7 +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.Summary'] = true;
|
this._ready[GroupStore.STATE_KEY.Summary] = true;
|
||||||
this._notifyListeners();
|
this._notifyListeners();
|
||||||
}).catch((err) => {
|
}).catch((err) => {
|
||||||
this.emit('error', err);
|
this.emit('error', err);
|
||||||
|
@ -81,7 +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.GroupRooms'] = true;
|
this._ready[GroupStore.STATE_KEY.GroupRooms] = true;
|
||||||
this._notifyListeners();
|
this._notifyListeners();
|
||||||
}).catch((err) => {
|
}).catch((err) => {
|
||||||
this.emit('error', err);
|
this.emit('error', err);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue