Fixed DM channels not opening (#3336)
Этот коммит содержится в:
коммит произвёл
Joram Wilander
родитель
70711c82a3
Коммит
804705e0c5
@@ -2,12 +2,23 @@
|
|||||||
// See License.txt for license information.
|
// See License.txt for license information.
|
||||||
|
|
||||||
import {browserHistory} from 'react-router';
|
import {browserHistory} from 'react-router';
|
||||||
|
import * as Utils from 'utils/utils.jsx';
|
||||||
import TeamStore from 'stores/team_store.jsx';
|
import TeamStore from 'stores/team_store.jsx';
|
||||||
|
import UserStore from 'stores/user_store.jsx';
|
||||||
import Client from 'utils/web_client.jsx';
|
import Client from 'utils/web_client.jsx';
|
||||||
|
|
||||||
export function goToChannel(channel) {
|
export function goToChannel(channel) {
|
||||||
browserHistory.push(TeamStore.getCurrentTeamRelativeUrl() + '/channels/' + channel.name);
|
if (channel.fake) {
|
||||||
|
Utils.openDirectChannelToUser(
|
||||||
|
UserStore.getProfileByUsername(channel.display_name),
|
||||||
|
() => {
|
||||||
|
browserHistory.push(TeamStore.getCurrentTeamRelativeUrl() + '/channels/' + channel.name);
|
||||||
|
},
|
||||||
|
null
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
browserHistory.push(TeamStore.getCurrentTeamRelativeUrl() + '/channels/' + channel.name);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function executeCommand(channelId, message, suggest, success, error) {
|
export function executeCommand(channelId, message, suggest, success, error) {
|
||||||
|
|||||||
@@ -71,6 +71,7 @@ export default class Sidebar extends React.Component {
|
|||||||
state.loadingDMChannel = -1;
|
state.loadingDMChannel = -1;
|
||||||
this.state = state;
|
this.state = state;
|
||||||
}
|
}
|
||||||
|
|
||||||
getTotalUnreadCount() {
|
getTotalUnreadCount() {
|
||||||
let msgs = 0;
|
let msgs = 0;
|
||||||
let mentions = 0;
|
let mentions = 0;
|
||||||
@@ -83,6 +84,7 @@ export default class Sidebar extends React.Component {
|
|||||||
|
|
||||||
return {msgs, mentions};
|
return {msgs, mentions};
|
||||||
}
|
}
|
||||||
|
|
||||||
getStateFromStores() {
|
getStateFromStores() {
|
||||||
const members = ChannelStore.getAllMembers();
|
const members = ChannelStore.getAllMembers();
|
||||||
const currentChannelId = ChannelStore.getCurrentId();
|
const currentChannelId = ChannelStore.getCurrentId();
|
||||||
@@ -165,12 +167,14 @@ export default class Sidebar extends React.Component {
|
|||||||
document.addEventListener('keydown', this.navigateChannelShortcut);
|
document.addEventListener('keydown', this.navigateChannelShortcut);
|
||||||
document.addEventListener('keydown', this.navigateUnreadChannelShortcut);
|
document.addEventListener('keydown', this.navigateUnreadChannelShortcut);
|
||||||
}
|
}
|
||||||
|
|
||||||
shouldComponentUpdate(nextProps, nextState) {
|
shouldComponentUpdate(nextProps, nextState) {
|
||||||
if (!Utils.areObjectsEqual(nextState, this.state)) {
|
if (!Utils.areObjectsEqual(nextState, this.state)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
componentDidUpdate(prevProps, prevState) {
|
componentDidUpdate(prevProps, prevState) {
|
||||||
this.updateTitle();
|
this.updateTitle();
|
||||||
this.updateUnreadIndicators();
|
this.updateUnreadIndicators();
|
||||||
@@ -190,6 +194,7 @@ export default class Sidebar extends React.Component {
|
|||||||
$('.app__body .sidebar--left').removeClass('move--right');
|
$('.app__body .sidebar--left').removeClass('move--right');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
componentWillUnmount() {
|
componentWillUnmount() {
|
||||||
ChannelStore.removeChangeListener(this.onChange);
|
ChannelStore.removeChangeListener(this.onChange);
|
||||||
UserStore.removeChangeListener(this.onChange);
|
UserStore.removeChangeListener(this.onChange);
|
||||||
@@ -199,9 +204,11 @@ export default class Sidebar extends React.Component {
|
|||||||
document.removeEventListener('keydown', this.navigateChannelShortcut);
|
document.removeEventListener('keydown', this.navigateChannelShortcut);
|
||||||
document.removeEventListener('keydown', this.navigateUnreadChannelShortcut);
|
document.removeEventListener('keydown', this.navigateUnreadChannelShortcut);
|
||||||
}
|
}
|
||||||
|
|
||||||
onChange() {
|
onChange() {
|
||||||
this.setState(this.getStateFromStores());
|
this.setState(this.getStateFromStores());
|
||||||
}
|
}
|
||||||
|
|
||||||
updateTitle() {
|
updateTitle() {
|
||||||
const channel = ChannelStore.getCurrent();
|
const channel = ChannelStore.getCurrent();
|
||||||
if (channel && this.state.currentTeam) {
|
if (channel && this.state.currentTeam) {
|
||||||
@@ -224,9 +231,11 @@ export default class Sidebar extends React.Component {
|
|||||||
document.title = mentionTitle + unreadTitle + currentChannelName + ' - ' + this.state.currentTeam.display_name + ' ' + currentSiteName;
|
document.title = mentionTitle + unreadTitle + currentChannelName + ' - ' + this.state.currentTeam.display_name + ' ' + currentSiteName;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onScroll() {
|
onScroll() {
|
||||||
this.updateUnreadIndicators();
|
this.updateUnreadIndicators();
|
||||||
}
|
}
|
||||||
|
|
||||||
updateUnreadIndicators() {
|
updateUnreadIndicators() {
|
||||||
const container = $(ReactDOM.findDOMNode(this.refs.container));
|
const container = $(ReactDOM.findDOMNode(this.refs.container));
|
||||||
|
|
||||||
@@ -254,6 +263,7 @@ export default class Sidebar extends React.Component {
|
|||||||
showBottomUnread
|
showBottomUnread
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
updateScrollbarOnChannelChange(channel) {
|
updateScrollbarOnChannelChange(channel) {
|
||||||
const curChannel = this.refs[channel.name].getBoundingClientRect();
|
const curChannel = this.refs[channel.name].getBoundingClientRect();
|
||||||
if ((curChannel.top - Constants.CHANNEL_SCROLL_ADJUSTMENT < 0) || (curChannel.top + curChannel.height > this.refs.container.getBoundingClientRect().height)) {
|
if ((curChannel.top - Constants.CHANNEL_SCROLL_ADJUSTMENT < 0) || (curChannel.top + curChannel.height > this.refs.container.getBoundingClientRect().height)) {
|
||||||
@@ -261,6 +271,7 @@ export default class Sidebar extends React.Component {
|
|||||||
$('.nav-pills__container').perfectScrollbar('update');
|
$('.nav-pills__container').perfectScrollbar('update');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
navigateChannelShortcut(e) {
|
navigateChannelShortcut(e) {
|
||||||
if (e.altKey && !e.shiftKey && (e.keyCode === Constants.KeyCodes.UP || e.keyCode === Constants.KeyCodes.DOWN)) {
|
if (e.altKey && !e.shiftKey && (e.keyCode === Constants.KeyCodes.UP || e.keyCode === Constants.KeyCodes.DOWN)) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
@@ -284,6 +295,7 @@ export default class Sidebar extends React.Component {
|
|||||||
this.updateScrollbarOnChannelChange(nextChannel);
|
this.updateScrollbarOnChannelChange(nextChannel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
navigateUnreadChannelShortcut(e) {
|
navigateUnreadChannelShortcut(e) {
|
||||||
if (e.altKey && e.shiftKey && (e.keyCode === Constants.KeyCodes.UP || e.keyCode === Constants.KeyCodes.DOWN)) {
|
if (e.altKey && e.shiftKey && (e.keyCode === Constants.KeyCodes.UP || e.keyCode === Constants.KeyCodes.DOWN)) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
@@ -318,9 +330,11 @@ export default class Sidebar extends React.Component {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
getDisplayedChannels() {
|
getDisplayedChannels() {
|
||||||
return this.state.publicChannels.concat(this.state.privateChannels).concat(this.state.directChannels).concat(this.state.directNonTeamChannels);
|
return this.state.publicChannels.concat(this.state.privateChannels).concat(this.state.directChannels).concat(this.state.directNonTeamChannels);
|
||||||
}
|
}
|
||||||
|
|
||||||
handleLeaveDirectChannel(e, channel) {
|
handleLeaveDirectChannel(e, channel) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
@@ -359,6 +373,7 @@ export default class Sidebar extends React.Component {
|
|||||||
showNewChannelModal(type) {
|
showNewChannelModal(type) {
|
||||||
this.setState({newChannelModalType: type});
|
this.setState({newChannelModalType: type});
|
||||||
}
|
}
|
||||||
|
|
||||||
hideNewChannelModal() {
|
hideNewChannelModal() {
|
||||||
this.setState({newChannelModalType: ''});
|
this.setState({newChannelModalType: ''});
|
||||||
}
|
}
|
||||||
@@ -366,6 +381,7 @@ export default class Sidebar extends React.Component {
|
|||||||
showMoreDirectChannelsModal() {
|
showMoreDirectChannelsModal() {
|
||||||
this.setState({showDirectChannelsModal: true});
|
this.setState({showDirectChannelsModal: true});
|
||||||
}
|
}
|
||||||
|
|
||||||
hideMoreDirectChannelsModal() {
|
hideMoreDirectChannelsModal() {
|
||||||
this.setState({showDirectChannelsModal: false});
|
this.setState({showDirectChannelsModal: false});
|
||||||
}
|
}
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user