Commit 9ae49c99c4e15aee20a0b51e586caccd37d33d1e
count yupps
Dominic Tarr committed on 5/16/2016, 10:52:55 AMParent: 59ec50547ac8f97c3f287fc4854692b515223939
Files changed
modules/like.js | changed |
modules/like.js | ||
---|---|---|
@@ -1,7 +1,8 @@ | ||
1 | 1 | |
2 | 2 | var h = require('hyperscript') |
3 | 3 | var u = require('../util') |
4 | +var pull = require('pull-stream') | |
4 | 5 | |
5 | 6 | exports.message_link = [] |
6 | 7 | |
7 | 8 | exports.message_content = function (msg, sbot) { |
@@ -11,17 +12,43 @@ | ||
11 | 12 | u.decorate(exports.message_link, link, function (d, e, v) { return d(e, v, sbot) }) |
12 | 13 | ) |
13 | 14 | } |
14 | 15 | |
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 | + | |
15 | 34 | exports.message_action = function (msg, sbot) { |
16 | 35 | if(msg.value.content.type !== 'vote') |
17 | 36 | return h('a', {href: '#', onclick: function () { |
18 | 37 | var yup = { |
19 | 38 | type: 'vote', |
20 | 39 | vote: { link: msg.key, value: 1, expression: 'yup' } |
21 | 40 | } |
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 | + } | |
22 | 47 | //TODO: actually publish... |
23 | 48 | |
24 | 49 | alert(JSON.stringify(yup, null, 2)) |
25 | 50 | }}, 'yup') |
26 | 51 | |
27 | 52 | } |
53 | + | |
54 | + |
Built with git-ssb-web