update rename channel modal to not refresh page on channel name change
Этот коммит содержится в:
@@ -63,12 +63,14 @@ module.exports = React.createClass({
|
|||||||
|
|
||||||
Client.updateChannel(channel,
|
Client.updateChannel(channel,
|
||||||
function(data, text, req) {
|
function(data, text, req) {
|
||||||
|
$(this.refs.modal.getDOMNode()).modal('hide');
|
||||||
|
|
||||||
|
AsyncClient.getChannel(channel.id);
|
||||||
|
utils.updateTabTitle(channel.display_name);
|
||||||
|
utils.updateAddressBar(channel.name);
|
||||||
|
|
||||||
this.refs.display_name.getDOMNode().value = "";
|
this.refs.display_name.getDOMNode().value = "";
|
||||||
this.refs.channel_name.getDOMNode().value = "";
|
this.refs.channel_name.getDOMNode().value = "";
|
||||||
|
|
||||||
$('#' + this.props.modalId).modal('hide');
|
|
||||||
window.location.href = TeamStore.getCurrentTeamUrl() + '/channels/' + this.state.channel_name;
|
|
||||||
AsyncClient.getChannel(channel.id);
|
|
||||||
}.bind(this),
|
}.bind(this),
|
||||||
function(err) {
|
function(err) {
|
||||||
state.server_error = err.message;
|
state.server_error = err.message;
|
||||||
|
|||||||
@@ -102,7 +102,20 @@ function getStateFromStores() {
|
|||||||
}
|
}
|
||||||
readDirectChannels = readDirectChannels.slice(index);
|
readDirectChannels = readDirectChannels.slice(index);
|
||||||
|
|
||||||
showDirectChannels.sort(function(a, b) {
|
showDirectChannels.sort(function directSort(a, b) {
|
||||||
|
if (a.display_name < b.display_name) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if (a.display_name > b.display_name) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
var channels = ChannelStore.getAll();
|
||||||
|
if (channels) {
|
||||||
|
channels.sort(function chanSort(a, b) {
|
||||||
if (a.display_name < b.display_name) {
|
if (a.display_name < b.display_name) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -114,8 +127,8 @@ function getStateFromStores() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
active_id: currentId,
|
activeId: currentId,
|
||||||
channels: ChannelStore.getAll(),
|
channels: channels,
|
||||||
members: members,
|
members: members,
|
||||||
showDirectChannels: showDirectChannels,
|
showDirectChannels: showDirectChannels,
|
||||||
hideDirectChannels: readDirectChannels
|
hideDirectChannels: readDirectChannels
|
||||||
|
|||||||
@@ -732,20 +732,19 @@ module.exports.isValidUsername = function (name) {
|
|||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports.switchChannel = function(channel, teammate_name) {
|
function switchChannel(channel, teammateName) {
|
||||||
AppDispatcher.handleViewAction({
|
AppDispatcher.handleViewAction({
|
||||||
type: ActionTypes.CLICK_CHANNEL,
|
type: ActionTypes.CLICK_CHANNEL,
|
||||||
name: channel.name,
|
name: channel.name,
|
||||||
id: channel.id
|
id: channel.id
|
||||||
});
|
});
|
||||||
|
|
||||||
var teamURL = window.location.href.split('/channels')[0];
|
updateAddressBar(channel.name);
|
||||||
history.replaceState('data', '', teamURL + '/channels/' + channel.name);
|
|
||||||
|
|
||||||
if (channel.type === 'D' && teammate_name) {
|
if (channel.type === 'D' && teammateName) {
|
||||||
document.title = teammate_name + " " + document.title.substring(document.title.lastIndexOf("-"));
|
updateTabTitle(teammateName);
|
||||||
} else {
|
} else {
|
||||||
document.title = channel.display_name + " " + document.title.substring(document.title.lastIndexOf("-"));
|
updateTabTitle(channel.display_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
AsyncClient.getChannels(true, true, true);
|
AsyncClient.getChannels(true, true, true);
|
||||||
@@ -759,6 +758,18 @@ module.exports.switchChannel = function(channel, teammate_name) {
|
|||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
module.exports.switchChannel = switchChannel;
|
||||||
|
|
||||||
|
function updateTabTitle(name) {
|
||||||
|
document.title = name + ' ' + document.title.substring(document.title.lastIndexOf('-'));
|
||||||
|
}
|
||||||
|
module.exports.updateTabTitle = updateTabTitle;
|
||||||
|
|
||||||
|
function updateAddressBar(channelName) {
|
||||||
|
var teamURL = window.location.href.split('/channels')[0];
|
||||||
|
history.replaceState('data', '', teamURL + '/channels/' + channelName);
|
||||||
|
}
|
||||||
|
module.exports.updateAddressBar = updateAddressBar;
|
||||||
|
|
||||||
module.exports.isMobile = function() {
|
module.exports.isMobile = function() {
|
||||||
return screen.width <= 768;
|
return screen.width <= 768;
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user