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