git ssb

16+

Dominic / patchbay



Tree: 81f1fc4beaf000077eb2a907b7f3cee091bce3ba

Files: 81f1fc4beaf000077eb2a907b7f3cee091bce3ba / message / html / meta / likes.js

799 bytesRaw
1const nest = require('depnest')
2const { h, computed, map } = require('mutant')
3const ref = require('ssb-ref')
4
5exports.gives = nest('message.html.meta')
6
7exports.needs = nest({
8 'about.obs.name': 'first',
9 'message.obs.likes': 'first'
10})
11
12exports.create = (api) => {
13 return nest('message.html.meta', likes)
14
15 function likes (msg) {
16 if (!ref.isMsgId(msg.key)) return
17
18 const symbol = '\u2713' // tick 🗸
19
20 var likes = api.message.obs.likes(msg.key)
21
22 var body = computed(likes, likes => likes.length > 4
23 ? likes.length + ' ' + symbol
24 : Array(likes.length).fill(symbol).join('')
25 )
26
27 var names = map(likes, id => api.about.obs.name(id))
28 var title = computed(names, names => names.map(n => '@' + n).join('\n'))
29
30 return h('a.likes', { title }, body)
31 }
32}
33

Built with git-ssb-web