Made ChannelInviteModal pull all channel members before rendering
Этот коммит содержится в:
@@ -20,9 +20,14 @@ export default class ChannelInviteModal extends React.Component {
|
|||||||
this.onListenerChange = this.onListenerChange.bind(this);
|
this.onListenerChange = this.onListenerChange.bind(this);
|
||||||
this.handleInvite = this.handleInvite.bind(this);
|
this.handleInvite = this.handleInvite.bind(this);
|
||||||
|
|
||||||
this.state = this.getStateFromStores();
|
// the state gets populated when the modal is shown
|
||||||
|
this.state = {};
|
||||||
}
|
}
|
||||||
shouldComponentUpdate(nextProps, nextState) {
|
shouldComponentUpdate(nextProps, nextState) {
|
||||||
|
if (!this.props.show && !nextProps.show) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (!Utils.areObjectsEqual(this.props, nextProps)) {
|
if (!Utils.areObjectsEqual(this.props, nextProps)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -34,13 +39,25 @@ export default class ChannelInviteModal extends React.Component {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
getStateFromStores() {
|
getStateFromStores() {
|
||||||
function getId(user) {
|
const users = UserStore.getActiveOnlyProfiles();
|
||||||
return user.id;
|
|
||||||
}
|
|
||||||
var users = UserStore.getActiveOnlyProfiles();
|
|
||||||
var memberIds = ChannelStore.getCurrentExtraInfo().members.map(getId);
|
|
||||||
|
|
||||||
var loading = $.isEmptyObject(users);
|
if ($.isEmptyObject(users)) {
|
||||||
|
return {
|
||||||
|
loading: true
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
// make sure we have all members of this channel before rendering
|
||||||
|
const extraInfo = ChannelStore.getCurrentExtraInfo();
|
||||||
|
if (extraInfo.member_count !== extraInfo.members.length) {
|
||||||
|
AsyncClient.getChannelExtraInfo(this.props.channel.id, -1);
|
||||||
|
|
||||||
|
return {
|
||||||
|
loading: true
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
const memberIds = extraInfo.members.map((user) => user.id);
|
||||||
|
|
||||||
var nonmembers = [];
|
var nonmembers = [];
|
||||||
for (var id in users) {
|
for (var id in users) {
|
||||||
@@ -55,7 +72,7 @@ export default class ChannelInviteModal extends React.Component {
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
nonmembers,
|
nonmembers,
|
||||||
loading
|
loading: false
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
onShow() {
|
onShow() {
|
||||||
|
|||||||
@@ -168,7 +168,7 @@ export function getMoreChannels(force) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getChannelExtraInfo(id) {
|
export function getChannelExtraInfo(id, memberLimit) {
|
||||||
let channelId;
|
let channelId;
|
||||||
if (id) {
|
if (id) {
|
||||||
channelId = id;
|
channelId = id;
|
||||||
@@ -185,6 +185,7 @@ export function getChannelExtraInfo(id) {
|
|||||||
|
|
||||||
client.getChannelExtraInfo(
|
client.getChannelExtraInfo(
|
||||||
channelId,
|
channelId,
|
||||||
|
memberLimit,
|
||||||
(data, textStatus, xhr) => {
|
(data, textStatus, xhr) => {
|
||||||
callTracker['getChannelExtraInfo_' + channelId] = 0;
|
callTracker['getChannelExtraInfo_' + channelId] = 0;
|
||||||
|
|
||||||
|
|||||||
@@ -824,10 +824,17 @@ export function getChannelCounts(success, error) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getChannelExtraInfo(id, success, error) {
|
export function getChannelExtraInfo(id, memberLimit, success, error) {
|
||||||
|
let url = '/api/v1/channels/' + id + '/extra_info';
|
||||||
|
|
||||||
|
if (memberLimit) {
|
||||||
|
url += '/' + memberLimit;
|
||||||
|
}
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: '/api/v1/channels/' + id + '/extra_info',
|
url,
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
|
contentType: 'application/json',
|
||||||
type: 'GET',
|
type: 'GET',
|
||||||
success,
|
success,
|
||||||
error: function onError(xhr, status, err) {
|
error: function onError(xhr, status, err) {
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user