v1.18.x
barisusakli 11 years ago
parent 82e721e854
commit 7c3dc4877a

@ -2,7 +2,7 @@
/* globals define, ajaxify, app, utils, socket, translator*/
define('forum/account/profile', ['forum/account/header'], function(header) {
define('forum/account/profile', ['forum/account/header', 'forum/infinitescroll'], function(header, infinitescroll) {
var Account = {},
yourid,
theirid,
@ -39,6 +39,8 @@ define('forum/account/profile', ['forum/account/header'], function(header) {
if (yourid !== theirid) {
socket.emit('user.increaseViewCount', theirid);
}
infinitescroll.init(loadMoreTopics);
};
function processPage() {
@ -82,5 +84,44 @@ define('forum/account/profile', ['forum/account/header'], function(header) {
}
function loadMoreTopics(direction) {
if(direction < 0 || !$('.user-recent-posts').length) {
return;
}
$('.loading-indicator').removeClass('hidden');
infinitescroll.loadMore('user.loadMoreRecentPosts', {
after: $('.user-recent-posts').attr('data-nextstart'),
uid: theirid
}, function(data, done) {
if (data.posts && data.posts.length) {
onPostsLoaded(data.posts, done);
$('.user-recent-posts').attr('data-nextstart', data.nextStart);
} else {
done();
}
$('.loading-indicator').addClass('hidden');
});
}
function onPostsLoaded(posts, callback) {
posts = posts.filter(function(post) {
return !$('.user-recent-posts div[data-pid=' + post.pid + ']').length;
});
if (!posts.length) {
return callback();
}
infinitescroll.parseAndTranslate('account/profile', 'posts', {posts: posts}, function(html) {
$('.user-recent-posts .loading-indicator').before(html);
html.find('span.timeago').timeago();
callback();
});
}
return Account;
});

@ -122,7 +122,7 @@ define('forum/recent', ['forum/infinitescroll'], function(infinitescroll) {
});
if (!topics.length) {
callback();
return callback();
}
infinitescroll.parseAndTranslate(templateName, 'topics', {topics: topics, showSelect: showSelect}, function(html) {

@ -166,6 +166,7 @@ accountsController.getAccount = function(req, res, next) {
return p && parseInt(p.deleted, 10) !== 1;
});
userData.nextStart = results.posts.nextStart;
userData.isFollowing = results.isFollowing;
if (!userData.profileviews) {

@ -5,6 +5,7 @@ var async = require('async'),
user = require('../user'),
groups = require('../groups'),
topics = require('../topics'),
posts = require('../posts'),
notifications = require('../notifications'),
messaging = require('../messaging'),
plugins = require('../plugins'),
@ -329,6 +330,16 @@ SocketUser.loadMore = function(socket, data, callback) {
});
};
SocketUser.loadMoreRecentPosts = function(socket, data, callback) {
if(!data || !data.uid || !utils.isNumber(data.after)) {
return callback(new Error('[[error:invalid-data]]'));
}
var start = Math.max(0, parseInt(data.after, 10)),
end = start + 9;
posts.getPostsByUid(socket.uid, data.uid, start, end, callback);
};
SocketUser.setStatus = function(socket, status, callback) {
if (!socket.uid) {

Loading…
Cancel
Save