git ssb

2+

mixmix / ticktack



Tree: 87346349dd7d0ff160bde53ada8894333856c461

Files: 87346349dd7d0ff160bde53ada8894333856c461 / message / html / commentsCount.js

827 bytesRaw
1var { h, computed, throttle, when } = require('mutant')
2var nest = require('depnest')
3
4exports.needs = nest({
5 'keys.sync.id': 'first',
6 'message.obs.likes': 'first'
7})
8
9exports.gives = nest('message.html.commentsCount')
10
11exports.create = (api) => {
12 return nest('message.html.commentsCount', function commentsCount (thread) {
13 var count = computed(throttle(thread.messages, 500), msgs => {
14 return msgs
15 .filter(msg => msg.value.content.root) // exclude root message / blog
16 .filter(msg => {
17 if (msg.value.content.type !== 'post') console.log(msg.value.content.type)
18 return msg.value.content.type === 'post'
19 })
20 .length
21 })
22
23 return h('CommentsCount', [
24 h('i.fa', { className: 'fa-commenting-o' }),
25 h('div.count', when(count, count))
26 ])
27 })
28}
29

Built with git-ssb-web