Only cache 3 post views at a time (#2818)
Этот коммит содержится в:
коммит произвёл
Corey Hulen
родитель
65a2427b90
Коммит
3dbb5ab4cc
@@ -16,6 +16,8 @@ import {createChannelIntroMessage} from 'utils/channel_intro_messages.jsx';
|
|||||||
|
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
|
||||||
|
const MAXIMUM_CACHED_VIEWS = 3;
|
||||||
|
|
||||||
export default class PostsViewContainer extends React.Component {
|
export default class PostsViewContainer extends React.Component {
|
||||||
constructor() {
|
constructor() {
|
||||||
super();
|
super();
|
||||||
@@ -105,6 +107,12 @@ export default class PostsViewContainer extends React.Component {
|
|||||||
|
|
||||||
let newIndex = channels.indexOf(channelId);
|
let newIndex = channels.indexOf(channelId);
|
||||||
if (newIndex === -1) {
|
if (newIndex === -1) {
|
||||||
|
if (channels.length >= MAXIMUM_CACHED_VIEWS) {
|
||||||
|
channels.shift();
|
||||||
|
atTop.shift();
|
||||||
|
postLists.shift();
|
||||||
|
}
|
||||||
|
|
||||||
newIndex = channels.length;
|
newIndex = channels.length;
|
||||||
channels.push(channelId);
|
channels.push(channelId);
|
||||||
atTop[newIndex] = PostStore.getVisibilityAtTop(channelId);
|
atTop[newIndex] = PostStore.getVisibilityAtTop(channelId);
|
||||||
@@ -172,7 +180,7 @@ export default class PostsViewContainer extends React.Component {
|
|||||||
const isActive = (channels[i] === currentChannelId);
|
const isActive = (channels[i] === currentChannelId);
|
||||||
postListCtls.push(
|
postListCtls.push(
|
||||||
<PostsView
|
<PostsView
|
||||||
key={'postsviewkey' + i}
|
key={'postsviewkey' + channels[i]}
|
||||||
isActive={isActive}
|
isActive={isActive}
|
||||||
postList={postLists[i]}
|
postList={postLists[i]}
|
||||||
scrollType={this.state.scrollType}
|
scrollType={this.state.scrollType}
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user