aboutsummaryrefslogtreecommitdiff
path: root/lib/serve.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/serve.js')
-rw-r--r--lib/serve.js11
1 files changed, 7 insertions, 4 deletions
diff --git a/lib/serve.js b/lib/serve.js
index d8be4fc..ed8b20d 100644
--- a/lib/serve.js
+++ b/lib/serve.js
@@ -1297,12 +1297,14 @@ Serve.prototype.channel = function (path) {
)
}
-function threadHeads(msgs, rootId) {
+function threadHeads(msgs, rootId, opts) {
+ var includeVotes = opts && opts.includeVotes
return sort.heads(msgs.filter(function (msg) {
var c = msg.value && msg.value.content
return (c && (
c.type === 'web-root' ? c.site === rootId :
c.type === 'talenet-idea-comment_reply' ? c.ideaKey === rootId :
+ c.type === 'vote' ? includeVotes :
c.root === rootId))
|| msg.key === rootId
}))
@@ -1311,6 +1313,7 @@ function threadHeads(msgs, rootId) {
Serve.prototype.streamThreadWithComposer = function (opts) {
var self = this
var id = opts.root
+ var threadHeadsOpts = {includeVotes: self.app.voteBranches}
return ph('table', {class: 'ssb-msgs'}, u.readNext(next))
function next(cb) {
self.getMsgDecryptedMaybeOoo(id, function (err, rootMsg) {
@@ -1346,10 +1349,10 @@ Serve.prototype.streamThreadWithComposer = function (opts) {
)
function gotLinks(err, links) {
if (err) return cb(new Error(err.stack))
- var branches = threadHeads(links, threadRootId)
+ var branches = threadHeads(links, threadRootId, threadHeadsOpts)
cb(null, pull(
pull.values(sort(links)),
- pull.map(function (link) {
+ self.app.voteBranches && pull.map(function (link) {
var o = {}
for (var k in link) o[k] = link[k]
o.threadBranches = branches
@@ -1366,7 +1369,7 @@ Serve.prototype.streamThreadWithComposer = function (opts) {
root: threadRootId,
post: id,
branches: branches,
- postBranches: threadRootId !== id && threadHeads(links, id),
+ postBranches: threadRootId !== id && threadHeads(links, id, threadHeadsOpts),
placeholder: opts.placeholder,
channel: channel,
})