diff options
author | Joram Wilander <jwawilander@gmail.com> | 2016-04-28 10:55:50 -0400 |
---|---|---|
committer | Corey Hulen <corey@hulen.com> | 2016-04-28 07:55:50 -0700 |
commit | 3dbb5ab4cca74de7d7a00909927e1f034949052d (patch) | |
tree | e6a0c9cc6b319d9a9f7b0f74b81418e8210860ad /webapp | |
parent | 65a2427b90f3261d895f6b64a771d2362e896cb6 (diff) | |
download | chat-3dbb5ab4cca74de7d7a00909927e1f034949052d.tar.gz chat-3dbb5ab4cca74de7d7a00909927e1f034949052d.tar.bz2 chat-3dbb5ab4cca74de7d7a00909927e1f034949052d.zip |
Only cache 3 post views at a time (#2818)
Diffstat (limited to 'webapp')
-rw-r--r-- | webapp/components/posts_view_container.jsx | 10 |
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} |