reset number of posts to fetch on channel switch and fresh page load
Этот коммит содержится в:
@@ -8,6 +8,7 @@
|
|||||||
var BrowserStore = require('../stores/browser_store.jsx');
|
var BrowserStore = require('../stores/browser_store.jsx');
|
||||||
var AsyncClient = require('../utils/async_client.jsx');
|
var AsyncClient = require('../utils/async_client.jsx');
|
||||||
var SocketStore = require('../stores/socket_store.jsx');
|
var SocketStore = require('../stores/socket_store.jsx');
|
||||||
|
var ChannelStore = require('../stores/channel_store.jsx');
|
||||||
var Constants = require('../utils/constants.jsx');
|
var Constants = require('../utils/constants.jsx');
|
||||||
|
|
||||||
module.exports = React.createClass({
|
module.exports = React.createClass({
|
||||||
@@ -15,7 +16,7 @@ module.exports = React.createClass({
|
|||||||
|
|
||||||
/* Start initial aysnc loads */
|
/* Start initial aysnc loads */
|
||||||
AsyncClient.getMe();
|
AsyncClient.getMe();
|
||||||
AsyncClient.getPosts(true);
|
AsyncClient.getPosts(true, ChannelStore.getCurrentId(), Constants.POST_CHUNK_SIZE);
|
||||||
AsyncClient.getChannels(true, true);
|
AsyncClient.getChannels(true, true);
|
||||||
AsyncClient.getChannelExtraInfo(true);
|
AsyncClient.getChannelExtraInfo(true);
|
||||||
AsyncClient.findTeams();
|
AsyncClient.findTeams();
|
||||||
|
|||||||
@@ -272,17 +272,20 @@ module.exports.search = function(terms) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports.getPosts = function(force, id) {
|
module.exports.getPosts = function(force, id, maxPosts) {
|
||||||
if (PostStore.getCurrentPosts() == null || force) {
|
if (PostStore.getCurrentPosts() == null || force) {
|
||||||
var channelId = id ? id : ChannelStore.getCurrentId();
|
var channelId = id ? id : ChannelStore.getCurrentId();
|
||||||
|
|
||||||
if (isCallInProgress("getPosts_"+channelId)) return;
|
if (isCallInProgress("getPosts_"+channelId)) return;
|
||||||
|
|
||||||
var post_list = PostStore.getCurrentPosts();
|
var post_list = PostStore.getCurrentPosts();
|
||||||
|
|
||||||
|
if (!maxPosts) { maxPosts = Constants.POST_CHUNK_SIZE * Constants.MAX_POST_CHUNKS };
|
||||||
|
|
||||||
// if we already have more than POST_CHUNK_SIZE posts,
|
// if we already have more than POST_CHUNK_SIZE posts,
|
||||||
// let's get the amount we have but rounded up to next multiple of POST_CHUNK_SIZE,
|
// let's get the amount we have but rounded up to next multiple of POST_CHUNK_SIZE,
|
||||||
// with a max at 180
|
// with a max at maxPosts
|
||||||
var numPosts = post_list && post_list.order.length > 0 ? Math.min(180, Constants.POST_CHUNK_SIZE * Math.ceil(post_list.order.length / Constants.POST_CHUNK_SIZE)) : Constants.POST_CHUNK_SIZE;
|
var numPosts = post_list && post_list.order.length > 0 ? Math.min(maxPosts, Constants.POST_CHUNK_SIZE * Math.ceil(post_list.order.length / Constants.POST_CHUNK_SIZE)) : Constants.POST_CHUNK_SIZE;
|
||||||
|
|
||||||
if (channelId != null) {
|
if (channelId != null) {
|
||||||
callTracker["getPosts_"+channelId] = utils.getTimestamp();
|
callTracker["getPosts_"+channelId] = utils.getTimestamp();
|
||||||
|
|||||||
@@ -55,6 +55,7 @@ module.exports = {
|
|||||||
DEFAULT_CHANNEL: 'town-square',
|
DEFAULT_CHANNEL: 'town-square',
|
||||||
OFFTOPIC_CHANNEL: 'off-topic',
|
OFFTOPIC_CHANNEL: 'off-topic',
|
||||||
POST_CHUNK_SIZE: 60,
|
POST_CHUNK_SIZE: 60,
|
||||||
|
MAX_POST_CHUNKS: 3,
|
||||||
RESERVED_TEAM_NAMES: [
|
RESERVED_TEAM_NAMES: [
|
||||||
"www",
|
"www",
|
||||||
"web",
|
"web",
|
||||||
|
|||||||
@@ -720,7 +720,7 @@ module.exports.switchChannel = function(channel, teammate_name) {
|
|||||||
|
|
||||||
AsyncClient.getChannels(true, true, true);
|
AsyncClient.getChannels(true, true, true);
|
||||||
AsyncClient.getChannelExtraInfo(true);
|
AsyncClient.getChannelExtraInfo(true);
|
||||||
AsyncClient.getPosts(true, channel.id);
|
AsyncClient.getPosts(true, channel.id, Constants.POST_CHUNK_SIZE);
|
||||||
|
|
||||||
$('.inner__wrap').removeClass('move--right');
|
$('.inner__wrap').removeClass('move--right');
|
||||||
$('.sidebar--left').removeClass('move--right');
|
$('.sidebar--left').removeClass('move--right');
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user