summaryrefslogtreecommitdiffstats
path: root/webapp/components/posts_view_container.jsx
diff options
context:
space:
mode:
Diffstat (limited to 'webapp/components/posts_view_container.jsx')
-rw-r--r--webapp/components/posts_view_container.jsx10
1 files changed, 9 insertions, 1 deletions
diff --git a/webapp/components/posts_view_container.jsx b/webapp/components/posts_view_container.jsx
index a49c77f8d..edfa314f8 100644
--- a/webapp/components/posts_view_container.jsx
+++ b/webapp/components/posts_view_container.jsx
@@ -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}