mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-29 18:16:17 +01:00
closes #2089
This commit is contained in:
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
/* globals define, ajaxify, app, utils, socket, translator*/
|
/* 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 = {},
|
var Account = {},
|
||||||
yourid,
|
yourid,
|
||||||
theirid,
|
theirid,
|
||||||
@@ -39,6 +39,8 @@ define('forum/account/profile', ['forum/account/header'], function(header) {
|
|||||||
if (yourid !== theirid) {
|
if (yourid !== theirid) {
|
||||||
socket.emit('user.increaseViewCount', theirid);
|
socket.emit('user.increaseViewCount', theirid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
infinitescroll.init(loadMoreTopics);
|
||||||
};
|
};
|
||||||
|
|
||||||
function processPage() {
|
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;
|
return Account;
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -122,7 +122,7 @@ define('forum/recent', ['forum/infinitescroll'], function(infinitescroll) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (!topics.length) {
|
if (!topics.length) {
|
||||||
callback();
|
return callback();
|
||||||
}
|
}
|
||||||
|
|
||||||
infinitescroll.parseAndTranslate(templateName, 'topics', {topics: topics, showSelect: showSelect}, function(html) {
|
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;
|
return p && parseInt(p.deleted, 10) !== 1;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
userData.nextStart = results.posts.nextStart;
|
||||||
userData.isFollowing = results.isFollowing;
|
userData.isFollowing = results.isFollowing;
|
||||||
|
|
||||||
if (!userData.profileviews) {
|
if (!userData.profileviews) {
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ var async = require('async'),
|
|||||||
user = require('../user'),
|
user = require('../user'),
|
||||||
groups = require('../groups'),
|
groups = require('../groups'),
|
||||||
topics = require('../topics'),
|
topics = require('../topics'),
|
||||||
|
posts = require('../posts'),
|
||||||
notifications = require('../notifications'),
|
notifications = require('../notifications'),
|
||||||
messaging = require('../messaging'),
|
messaging = require('../messaging'),
|
||||||
plugins = require('../plugins'),
|
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) {
|
SocketUser.setStatus = function(socket, status, callback) {
|
||||||
if (!socket.uid) {
|
if (!socket.uid) {
|
||||||
|
|||||||
Reference in New Issue
Block a user