git ssb

16+

Dominic / patchbay



Commit 9ae49c99c4e15aee20a0b51e586caccd37d33d1e

count yupps

Dominic Tarr committed on 5/16/2016, 10:52:55 AM
Parent: 59ec50547ac8f97c3f287fc4854692b515223939

Files changed

modules/like.jschanged
modules/like.jsView
@@ -1,7 +1,8 @@
11
22 var h = require('hyperscript')
33 var u = require('../util')
4+var pull = require('pull-stream')
45
56 exports.message_link = []
67
78 exports.message_content = function (msg, sbot) {
@@ -11,17 +12,43 @@
1112 u.decorate(exports.message_link, link, function (d, e, v) { return d(e, v, sbot) })
1213 )
1314 }
1415
16+exports.message_meta = function (msg, sbot) {
17+
18+ var yupps = h('a')
19+
20+ pull(
21+ sbot.links({dest: msg.key, rel: 'vote'}),
22+ pull.collect(function (err, votes) {
23+ if(votes.length === 1)
24+ yupps.textContent = ' 1 yup'
25+ if(votes.length)
26+ yupps.textContent = ' ' + votes.length + ' yupps'
27+ })
28+ )
29+
30+
31+ return yupps
32+}
33+
1534 exports.message_action = function (msg, sbot) {
1635 if(msg.value.content.type !== 'vote')
1736 return h('a', {href: '#', onclick: function () {
1837 var yup = {
1938 type: 'vote',
2039 vote: { link: msg.key, value: 1, expression: 'yup' }
2140 }
41+ if(msg.value.content.recps) {
42+ yup.recps = msg.value.content.recps.map(function (e) {
43+ return e.link || e
44+ })
45+ yup.private = true
46+ }
2247 //TODO: actually publish...
2348
2449 alert(JSON.stringify(yup, null, 2))
2550 }}, 'yup')
2651
2752 }
53+
54+

Built with git-ssb-web