Commit ec8d61f431d404b2667225801a0350e1869029d0
add names of people who liked back to te like "title"
mixmix committed on 11/24/2018, 2:51:47 AMParent: 2f83e7af39eb4c09a1137daf878303e383a8ed3c
Files changed
message/html/like.js | changed |
message/html/like.js | |||
---|---|---|---|
@@ -1,17 +1,18 @@ | |||
1 | -const { h, computed } = require('mutant') | ||
1 … | +const { h, computed, map } = require('mutant') | ||
2 | 2 … | const nest = require('depnest') | |
3 | 3 … | const Scuttle = require('scuttle-thread') | |
4 | 4 … | const { isLink } = require('ssb-ref') | |
5 | 5 … | ||
6 … | +exports.gives = nest('message.html.like') | ||
7 … | + | ||
6 | 8 … | exports.needs = nest({ | |
9 … | + 'about.obs.name': 'first', | ||
7 | 10 … | 'keys.sync.id': 'first', | |
8 | 11 … | 'message.obs.likes': 'first', | |
9 | 12 … | 'sbot.obs.connection': 'first' | |
10 | 13 … | }) | |
11 | 14 … | ||
12 | -exports.gives = nest('message.html.like') | ||
13 | - | ||
14 | 15 … | exports.create = (api) => { | |
15 | 16 … | return nest('message.html.like', like) | |
16 | 17 … | ||
17 | 18 … | function like (msg) { | |
@@ -22,14 +23,19 @@ | |||
22 | 23 … | // - only update after I click like/ unlike | |
23 | 24 … | ||
24 | 25 … | if (!isLink(msg.key)) return | |
25 | 26 … | ||
26 | - return computed(api.message.obs.likes(msg.key), likes => { | ||
27 … | + const likes = api.message.obs.likes(msg.key) | ||
28 … | + const names = map(likes, id => api.about.obs.name(id)) | ||
29 … | + // TODO should really just calculate this on hover ... | ||
30 … | + | ||
31 … | + return computed([likes, names], (likes, names) => { | ||
27 | 32 … | const iLike = likes.includes(id) | |
28 | 33 … | ||
29 | 34 … | return h('MessageLike', | |
30 | 35 … | { | |
31 | 36 … | className: iLike ? '-liked' : '', | |
37 … | + title: names.join('\n'), | ||
32 | 38 … | 'ev-click': () => publishLike(msg, !iLike) | |
33 | 39 … | }, | |
34 | 40 … | [ | |
35 | 41 … | h('span.count', likes.length ? likes.length : ''), |
Built with git-ssb-web