Skip to content

Node.js based forum software built for the modern web

removed dupe code

barisusakli0d7e72be51f5
diff --git a/public/src/client/account/topics.js b/public/src/client/account/topics.js
index 3242f0395e..ed0f50bc88 100644
--- a/public/src/client/account/topics.js
+++ b/public/src/client/account/topics.js
@@ -1,13 +1,21 @@
'use strict';
-/* globals define, app, socket, utils */
+/* globals define, app, socket, utils, config, ajaxify */
define('forum/account/topics', ['forum/account/header', 'forum/infinitescroll'], function(header, infinitescroll) {
var AccountTopics = {};
+ var template, set;
AccountTopics.init = function() {
header.init();
+ AccountTopics.handleInfiniteScroll('account/topics', 'uid:' + ajaxify.variables.get('theirid') + ':topics');
+ };
+
+ AccountTopics.handleInfiniteScroll = function(_template, _set) {
+ template = _template;
+ set = _set;
+
if (!config.usePagination) {
infinitescroll.init(loadMore);
}
@@ -19,15 +27,15 @@ define('forum/account/topics', ['forum/account/header', 'forum/infinitescroll'],
}
infinitescroll.loadMore('topics.loadMoreFromSet', {
- set: 'uid:' + $('.account-username-box').attr('data-uid') + ':topics',
+ set: set,
after: $('[component="category"]').attr('data-nextstart')
}, function(data, done) {
-
if (data.topics && data.topics.length) {
onTopicsLoaded(data.topics, done);
} else {
done();
}
+
$('[component="category"]').attr('data-nextstart', data.nextStart);
});
}
diff --git a/public/src/client/account/watched.js b/public/src/client/account/watched.js
index b9f7fcc5f7..56fd52d0d4 100644
--- a/public/src/client/account/watched.js
+++ b/public/src/client/account/watched.js
@@ -1,45 +1,14 @@
'use strict';
/* globals define, app, socket, utils */
-define('forum/account/watched', ['forum/account/header', 'forum/infinitescroll'], function(header, infinitescroll) {
+define('forum/account/watched', ['forum/account/header', 'forum/account/topics'], function(header, topics) {
var AccountWatched = {};
AccountWatched.init = function() {
header.init();
- if (!config.usePagination) {
- infinitescroll.init(loadMore);
- }
+ topics.handleInfiniteScroll('account/watched', 'uid:' + ajaxify.variables.get('theirid') + ':followed_tids');
};
- function loadMore(direction) {
- if (direction < 0) {
- return;
- }
-
- infinitescroll.loadMore('topics.loadMoreFromSet', {
- set: 'uid:' + $('.account-username-box').attr('data-uid') + ':followed_tids',
- after: $('[component="category"]').attr('data-nextstart')
- }, function(data, done) {
- if (data.topics && data.topics.length) {
- onTopicsLoaded(data.topics, done);
- } else {
- done();
- }
- $('[component="category"]').attr('data-nextstart', data.nextStart);
- });
- }
-
- function onTopicsLoaded(topics, callback) {
- infinitescroll.parseAndTranslate('account/watched', 'topics', {topics: topics}, function(html) {
- $('[component="category"]').append(html);
- html.find('.timeago').timeago();
- app.createUserTooltips();
- utils.makeNumbersHumanReadable(html.find('.human-readable-number'));
- $(window).trigger('action:topics.loaded');
- callback();
- });
- }
-
return AccountWatched;
});