Fixed issue with channel name in url and added loading icon to replace 'Join' button for slow connections
Этот коммит содержится в:
@@ -24,6 +24,7 @@ export default class MoreChannels extends React.Component {
|
|||||||
|
|
||||||
var initState = getStateFromStores();
|
var initState = getStateFromStores();
|
||||||
initState.channelType = '';
|
initState.channelType = '';
|
||||||
|
initState.joiningChannel = -1;
|
||||||
this.state = initState;
|
this.state = initState;
|
||||||
}
|
}
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
@@ -47,14 +48,17 @@ export default class MoreChannels extends React.Component {
|
|||||||
this.setState(newState);
|
this.setState(newState);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
handleJoin(id) {
|
handleJoin(channel, channelIndex) {
|
||||||
client.joinChannel(id,
|
this.setState({joiningChannel: channelIndex});
|
||||||
function joinSuccess(data) {
|
client.joinChannel(channel.id,
|
||||||
|
function joinSuccess() {
|
||||||
$(this.refs.modal.getDOMNode()).modal('hide');
|
$(this.refs.modal.getDOMNode()).modal('hide');
|
||||||
asyncClient.getChannel(id);
|
asyncClient.getChannel(channel.id);
|
||||||
utils.switchChannel(data);
|
utils.switchChannel(channel);
|
||||||
|
this.setState({joiningChannel: -1});
|
||||||
}.bind(this),
|
}.bind(this),
|
||||||
function joinFail(err) {
|
function joinFail(err) {
|
||||||
|
this.setState({joiningChannel: -1});
|
||||||
this.state.serverError = err.message;
|
this.state.serverError = err.message;
|
||||||
this.setState(this.state);
|
this.setState(this.state);
|
||||||
}.bind(this)
|
}.bind(this)
|
||||||
@@ -79,7 +83,20 @@ export default class MoreChannels extends React.Component {
|
|||||||
moreChannels = (
|
moreChannels = (
|
||||||
<table className='more-channel-table table'>
|
<table className='more-channel-table table'>
|
||||||
<tbody>
|
<tbody>
|
||||||
{channels.map(function cMap(channel) {
|
{channels.map(function cMap(channel, index) {
|
||||||
|
var joinButton;
|
||||||
|
if (self.state.joiningChannel === index) {
|
||||||
|
joinButton = (<img
|
||||||
|
className='join-channel-loading-gif'
|
||||||
|
src='/static/images/load.gif'
|
||||||
|
/>);
|
||||||
|
} else {
|
||||||
|
joinButton = (<button
|
||||||
|
onClick={self.handleJoin.bind(self, channel, index)}
|
||||||
|
className='btn btn-primary'>Join
|
||||||
|
</button>);
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<tr key={channel.id}>
|
<tr key={channel.id}>
|
||||||
<td>
|
<td>
|
||||||
@@ -87,10 +104,7 @@ export default class MoreChannels extends React.Component {
|
|||||||
<p className='more-channel-description'>{channel.description}</p>
|
<p className='more-channel-description'>{channel.description}</p>
|
||||||
</td>
|
</td>
|
||||||
<td className='td--action'>
|
<td className='td--action'>
|
||||||
<button
|
{joinButton}
|
||||||
onClick={self.handleJoin.bind(self, channel.id)}
|
|
||||||
className='btn btn-primary'>Join
|
|
||||||
</button>
|
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -124,7 +124,15 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.channel-loading-gif {
|
.channel-loading-gif {
|
||||||
height:15px;
|
height: 15px;
|
||||||
width:15px;
|
width: 15px;
|
||||||
margin-top:2px;
|
margin-top: 2px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.join-channel-loading-gif {
|
||||||
|
margin-top: 5px;
|
||||||
|
margin-left: 10px;
|
||||||
|
height: 25px;
|
||||||
|
width: 25px;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user