mirror of
https://github.com/mattermost/mattermost.git
synced 2025-02-25 18:55:24 -06:00
Only cache 3 post views at a time (#2818)
This commit is contained in:
committed by
Corey Hulen
parent
65a2427b90
commit
3dbb5ab4cc
@@ -16,6 +16,8 @@ import {createChannelIntroMessage} from 'utils/channel_intro_messages.jsx';
|
||||
|
||||
import React from 'react';
|
||||
|
||||
const MAXIMUM_CACHED_VIEWS = 3;
|
||||
|
||||
export default class PostsViewContainer extends React.Component {
|
||||
constructor() {
|
||||
super();
|
||||
@@ -105,6 +107,12 @@ export default class PostsViewContainer extends React.Component {
|
||||
|
||||
let newIndex = channels.indexOf(channelId);
|
||||
if (newIndex === -1) {
|
||||
if (channels.length >= MAXIMUM_CACHED_VIEWS) {
|
||||
channels.shift();
|
||||
atTop.shift();
|
||||
postLists.shift();
|
||||
}
|
||||
|
||||
newIndex = channels.length;
|
||||
channels.push(channelId);
|
||||
atTop[newIndex] = PostStore.getVisibilityAtTop(channelId);
|
||||
@@ -172,7 +180,7 @@ export default class PostsViewContainer extends React.Component {
|
||||
const isActive = (channels[i] === currentChannelId);
|
||||
postListCtls.push(
|
||||
<PostsView
|
||||
key={'postsviewkey' + i}
|
||||
key={'postsviewkey' + channels[i]}
|
||||
isActive={isActive}
|
||||
postList={postLists[i]}
|
||||
scrollType={this.state.scrollType}
|
||||
|
||||
Reference in New Issue
Block a user