From 3dbb5ab4cca74de7d7a00909927e1f034949052d Mon Sep 17 00:00:00 2001 From: Joram Wilander Date: Thu, 28 Apr 2016 10:55:50 -0400 Subject: Only cache 3 post views at a time (#2818) --- webapp/components/posts_view_container.jsx | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) 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(