git ssb

16+

Dominic / patchbay



Commit ec8d61f431d404b2667225801a0350e1869029d0

add names of people who liked back to te like "title"

mixmix committed on 11/24/2018, 2:51:47 AM
Parent: 2f83e7af39eb4c09a1137daf878303e383a8ed3c

Files changed

message/html/like.jschanged
message/html/like.jsView
@@ -1,17 +1,18 @@
1-const { h, computed } = require('mutant')
1 +const { h, computed, map } = require('mutant')
22 const nest = require('depnest')
33 const Scuttle = require('scuttle-thread')
44 const { isLink } = require('ssb-ref')
55
6 +exports.gives = nest('message.html.like')
7 +
68 exports.needs = nest({
9 + 'about.obs.name': 'first',
710 'keys.sync.id': 'first',
811 'message.obs.likes': 'first',
912 'sbot.obs.connection': 'first'
1013 })
1114
12-exports.gives = nest('message.html.like')
13-
1415 exports.create = (api) => {
1516 return nest('message.html.like', like)
1617
1718 function like (msg) {
@@ -22,14 +23,19 @@
2223 // - only update after I click like/ unlike
2324
2425 if (!isLink(msg.key)) return
2526
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) => {
2732 const iLike = likes.includes(id)
2833
2934 return h('MessageLike',
3035 {
3136 className: iLike ? '-liked' : '',
37 + title: names.join('\n'),
3238 'ev-click': () => publishLike(msg, !iLike)
3339 },
3440 [
3541 h('span.count', likes.length ? likes.length : ''),

Built with git-ssb-web