git ssb

16+

Dominic / patchbay



Tree: 4f38a991eff961ff071507e747fd5dba7a2a5e94

Files: 4f38a991eff961ff071507e747fd5dba7a2a5e94 / message / html / action / likes.js

803 bytesRaw
1const nest = require('depnest')
2const { h, computed, map } = require('mutant')
3const ref = require('ssb-ref')
4
5exports.gives = nest('message.html.action')
6
7exports.needs = nest({
8 'about.obs.name': 'first',
9 'message.obs.likes': 'first'
10})
11
12exports.create = (api) => {
13 return nest('message.html.action', 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