From 1692fca1c3eb2569620813caa59b6a4b82f1872a Mon Sep 17 00:00:00 2001 From: JoramWilander Date: Tue, 11 Aug 2015 11:18:15 -0400 Subject: update rename channel modal to not refresh page on channel name change --- web/react/components/rename_channel_modal.jsx | 10 ++++++---- web/react/components/sidebar.jsx | 19 ++++++++++++++++--- 2 files changed, 22 insertions(+), 7 deletions(-) (limited to 'web/react/components') diff --git a/web/react/components/rename_channel_modal.jsx b/web/react/components/rename_channel_modal.jsx index 57a684b33..93cb6ef21 100644 --- a/web/react/components/rename_channel_modal.jsx +++ b/web/react/components/rename_channel_modal.jsx @@ -63,12 +63,14 @@ module.exports = React.createClass({ Client.updateChannel(channel, function(data, text, req) { - this.refs.display_name.getDOMNode().value = ""; - this.refs.channel_name.getDOMNode().value = ""; + $(this.refs.modal.getDOMNode()).modal('hide'); - $('#' + this.props.modalId).modal('hide'); - window.location.href = TeamStore.getCurrentTeamUrl() + '/channels/' + this.state.channel_name; AsyncClient.getChannel(channel.id); + utils.updateTabTitle(channel.display_name); + utils.updateAddressBar(channel.name); + + this.refs.display_name.getDOMNode().value = ""; + this.refs.channel_name.getDOMNode().value = ""; }.bind(this), function(err) { state.server_error = err.message; diff --git a/web/react/components/sidebar.jsx b/web/react/components/sidebar.jsx index f6ac36f50..f4992d4e3 100644 --- a/web/react/components/sidebar.jsx +++ b/web/react/components/sidebar.jsx @@ -102,7 +102,20 @@ function getStateFromStores() { } 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) { return -1; } @@ -114,8 +127,8 @@ function getStateFromStores() { } return { - active_id: currentId, - channels: ChannelStore.getAll(), + activeId: currentId, + channels: channels, members: members, showDirectChannels: showDirectChannels, hideDirectChannels: readDirectChannels -- cgit v1.2.3-1-g7c22