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

Revert virtualised and auto load of posts #2622

Merged
merged 9 commits into from
Apr 8, 2019
Prev Previous commit
Next Next commit
Revert "MM-14800 Fix missing messages when switching to a team not pr…
…eviously loaded (#2562)"

This reverts commit 3537b03.
  • Loading branch information
sudheerDev committed Apr 5, 2019
commit 82b8b360a0a72d4ba5f142db72c440c6956c1be1
19 changes: 7 additions & 12 deletions components/post_view/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {withRouter} from 'react-router-dom';
import {getPosts, getPostsAfter, getPostsBefore, getPostThread} from 'mattermost-redux/actions/posts';
import {getChannel} from 'mattermost-redux/selectors/entities/channels';
import {makeGetPostsAroundPost, makeGetPostsInChannel} from 'mattermost-redux/selectors/entities/posts';
import {getCurrentUserId, getUser} from 'mattermost-redux/selectors/entities/users';
import {getCurrentUserId} from 'mattermost-redux/selectors/entities/users';
import {getTeamByName} from 'mattermost-redux/selectors/entities/teams';

import {increasePostVisibility} from 'actions/post_actions.jsx';
Expand All @@ -21,18 +21,17 @@ import PostList from './post_list.jsx';
// This function is added as a fail safe for the channel sync issue we have.
// When the user switches to a team for the first time we show the channel of previous team and then settle for the right channel after that
// This causes the scroll correction etc an issue because post_list is not mounted for new channel instead it is updated
const isChannelLoading = (params, channel, team, teammate) => {
const isChannelLoading = (params, channel, team) => {
if (params.postid) {
return false;
}

if (channel && team) {
if (channel.type !== Constants.DM_CHANNEL && channel.name !== params.identifier) {
return true;
} else if (channel.type === Constants.DM_CHANNEL && teammate && params.identifier !== `@${teammate.username}`) {
return true;
if (channel.type !== Constants.DM_CHANNEL && channel.type !== Constants.GM_CHANNEL) {
if (channel.name !== params.identifier) {
return true;
}
}

if (channel.team_id && channel.team_id !== team.id) {
return true;
}
Expand Down Expand Up @@ -60,12 +59,8 @@ function makeMapStateToProps() {

const channel = getChannel(state, ownProps.channelId);
const team = getTeamByName(state, ownProps.match.params.team);
let teammate;
if (channel.type === Constants.DM_CHANNEL && channel.teammate_id) {
teammate = getUser(state, channel.teammate_id);
}

const channelLoading = isChannelLoading(ownProps.match.params, channel, team, teammate);
const channelLoading = isChannelLoading(ownProps.match.params, channel, team);
const lastViewedAt = state.views.channel.lastChannelViewTime[ownProps.channelId];
const {postIds, postsObjById} = preparePostIdsForPostList(state, {posts, lastViewedAt, indicateNewMessages: true});

Expand Down
3 changes: 1 addition & 2 deletions components/post_view/post_list.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@ export default class PostList extends React.PureComponent {

this.loadingPosts = false;
this.extraPagesLoaded = 0;

const channelIntroMessage = PostListRowListIds.CHANNEL_INTRO_MESSAGE;
const isMobile = Utils.isMobile();
this.state = {
Expand Down Expand Up @@ -261,7 +260,7 @@ export default class PostList extends React.PureComponent {
}
} else {
this.loadingPosts = false;
if (this.mounted && this.props.posts) {
if (this.mounted) {
const atEnd = !moreToLoad && this.props.posts.length < this.props.postVisibility;
const newState = {
atEnd,
Expand Down