Skip to content
This repository has been archived by the owner on Mar 13, 2024. It is now read-only.

ICU-672 Fix undefined id error #738

Merged
merged 1 commit into from
Feb 7, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 0 additions & 54 deletions components/channel_view/channel_view.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,15 @@ import $ from 'jquery';
import PropTypes from 'prop-types';
import React from 'react';
import {FormattedMessage} from 'react-intl';
import {joinChannel} from 'mattermost-redux/actions/channels';

import * as UserAgent from 'utils/user_agent.jsx';
import deferComponentRender from 'components/deferComponentRender';
import Constants from 'utils/constants.jsx';
import ChannelStore from 'stores/channel_store';
import UserStore from 'stores/user_store';
import TeamStore from 'stores/team_store';
import {loadNewDMIfNeeded, loadNewGMIfNeeded} from 'actions/user_actions.jsx';
import * as GlobalActions from 'actions/global_actions.jsx';
import ChannelHeader from 'components/channel_header';
import CreatePost from 'components/create_post';
import FileUploadOverlay from 'components/file_upload_overlay.jsx';
import PostView from 'components/post_view';
import TutorialView from 'components/tutorial/tutorial_view.jsx';
import {clearMarks, mark, measure, trackEvent} from 'actions/diagnostics_actions.jsx';
import store from 'stores/redux_store.jsx';

const dispatch = store.dispatch;
const getState = store.getState;

export default class ChannelView extends React.PureComponent {
static propTypes = {
Expand All @@ -48,8 +37,6 @@ export default class ChannelView extends React.PureComponent {
constructor(props) {
super(props);

this.updateChannel(this.props);

this.createDeferredPostView();
}

Expand All @@ -60,46 +47,6 @@ export default class ChannelView extends React.PureComponent {
);
}

updateChannel(props) {
let channel;
const fakechannel = (new URLSearchParams(props.location.search)).get('fakechannel');
if (fakechannel) {
channel = JSON.parse(fakechannel);
} else {
channel = ChannelStore.getByName(props.match.params.channel);

if (channel && channel.type === Constants.DM_CHANNEL) {
loadNewDMIfNeeded(channel.id);
} else if (channel && channel.type === Constants.GM_CHANNEL) {
loadNewGMIfNeeded(channel.id);
}

if (channel) {
GlobalActions.emitChannelClickEvent(channel);
} else {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does removing updateChannel will not cause any side-effect?
Why not just get the channel name from props.match.params and use it accordingly?

    const {team, identifier} = props.match.params;
    const channelName = identifier.toLowerCase();

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like it may break the "fake channel" logic, but I don't actually know if that's been used for a long time. We had it in there for when we'd show random users in your DM list on first sign up even if the channels for them didn't exist so that we could create those channels when you did click on them.

I was actually wondering yesterday if we can just remove all that logic since I think that was the only place we used them, and we haven't automatically added DM users for a long time

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok. I will remove fake channel logic and retest.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we could just make a ticket and go with these changes if they work. The fake channel logic is split across the redux and web app, and it might even be in the mobile app even though that logic was removed probably 2 years ago

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for clearing up!

joinChannel(UserStore.getCurrentId(), TeamStore.getCurrentId(), null, props.match.params.channel)(dispatch, getState).then(
(result) => {
if (result.data) {
channel = result.data.channel;
if (channel && channel.type === Constants.DM_CHANNEL) {
loadNewDMIfNeeded(channel.id);
} else if (channel && channel.type === Constants.GM_CHANNEL) {
loadNewGMIfNeeded(channel.id);
}
GlobalActions.emitChannelClickEvent(channel);
} else if (result.error) {
if (props.match.params.team) {
props.history.push('/' + props.match.params.team + '/channels/town-square');
} else {
props.history.push('/');
}
}
}
);
}
}
}

componentDidMount() {
$('body').addClass('app__body');

Expand All @@ -115,7 +62,6 @@ export default class ChannelView extends React.PureComponent {

componentWillReceiveProps(nextProps) {
if (this.props.match.url !== nextProps.match.url) {
this.updateChannel(nextProps);
this.createDeferredPostView();
}
}
Expand Down