Node.js based forum software built for the modern web
Added ACP option to customise recent post
Julian Lam8eaff1492a0d
diff --git a/install/data/defaults.json b/install/data/defaults.jsonindex 45f426fb04..4ddf385e8a 100644--- a/install/data/defaults.json+++ b/install/data/defaults.json@@ -31,7 +31,7 @@"profileImageDimension": 128,"requireEmailConfirmation": 0,"allowProfileImageUploads": 1,- "teaserPost": "last",+ "teaserPost": "last-reply","allowPrivateGroups": 1,"unreadCutoff": 2,"bookmarkThreshold": 5diff --git a/src/categories/recentreplies.js b/src/categories/recentreplies.jsindex 7d42f053ff..e431a5cd59 100644--- a/src/categories/recentreplies.js+++ b/src/categories/recentreplies.js@@ -105,14 +105,7 @@ module.exports = function(Categories) {function (next) {topics.getTopicsFields(tids, ['tid', 'mainPid', 'slug', 'title', 'teaserPid', 'cid', 'postcount'], next);},- function (_topicData, next) {- topicData = _topicData;- topicData.forEach(function(topic) {- topic.teaserPid = topic.teaserPid || topic.mainPid;- });-- topics.getTeasers(topicData, next);- },+ async.apply(topics.getTeasers, topicData),function (teasers, next) {teasers.forEach(function(teaser, index) {if (teaser) {diff --git a/src/topics/teaser.js b/src/topics/teaser.jsindex b841219a25..9c752946ee 100644--- a/src/topics/teaser.js+++ b/src/topics/teaser.js@@ -26,7 +26,24 @@ module.exports = function(Topics) {topics.forEach(function(topic) {counts.push(topic && (parseInt(topic.postcount, 10) || 0));if (topic) {- teaserPids.push(meta.config.teaserPost === 'first' ? topic.mainPid : topic.teaserPid);+ if (topic.teaserPid === 'null') {+ delete topic.teaserPid;+ }++ switch(meta.config.teaserPost) {+ case 'first':+ teaserPids.push(topic.mainPid);+ break;++ case 'last-post':+ teaserPids.push(topic.teaserPid || topic.mainPid);+ break;++ case 'last-reply': // intentional fall-through+ default:+ teaserPids.push(topic.teaserPid);+ break;+ }}});@@ -113,7 +130,11 @@ module.exports = function(Topics) {}pid = pid || null;- Topics.setTopicField(tid, 'teaserPid', pid, callback);+ if (pid) {+ Topics.setTopicField(tid, 'teaserPid', pid, callback);+ } else {+ Topics.deleteTopicField(tid, 'teaserPid', callback);+ }});};};\ No newline at end of filediff --git a/src/views/admin/settings/post.tpl b/src/views/admin/settings/post.tplindex e37f51a40c..0855a34333 100644--- a/src/views/admin/settings/post.tpl+++ b/src/views/admin/settings/post.tpl@@ -83,7 +83,8 @@<div class="form-group"><label>Teaser Post</label><select class="form-control" data-field="teaserPost">- <option value="last">Last</option>+ <option value="last-post">Last – Show the latest post, including the original post, if no replies</option>+ <option value="last-reply">Last – Show the latest reply, or a "No replies" placeholder if no replies</option><option value="first">First</option></select></div>