git ssb

16+

Dominic / patchbay



Tree: 0317853c50ffacda585e8b019f18d3b8ff32329a

Files: 0317853c50ffacda585e8b019f18d3b8ff32329a / modules / like.js

1328 bytesRaw
1
2var h = require('hyperscript')
3var u = require('../util')
4var pull = require('pull-stream')
5
6exports.message_confirm = []
7exports.message_link = []
8
9exports.message_content = function (msg, sbot) {
10 if(msg.value.content.type !== 'vote') return
11 var link = msg.value.content.vote.link
12 return h('div', msg.value.content.vote.value > 0 ? 'yup' : 'nah',
13 u.decorate(exports.message_link, link, function (d, e, v) { return d(e, v, sbot) })
14 )
15}
16
17exports.message_meta = function (msg, sbot) {
18
19 var yupps = h('a')
20
21 pull(
22 sbot.links({dest: msg.key, rel: 'vote'}),
23 pull.collect(function (err, votes) {
24 if(votes.length === 1)
25 yupps.textContent = ' 1 yup'
26 if(votes.length)
27 yupps.textContent = ' ' + votes.length + ' yupps'
28 })
29 )
30
31 return yupps
32}
33
34exports.message_action = function (msg, sbot) {
35 if(msg.value.content.type !== 'vote')
36 return h('a', {href: '#', onclick: function () {
37 var yup = {
38 type: 'vote',
39 vote: { link: msg.key, value: 1, expression: 'yup' }
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 }
47 //TODO: actually publish...
48
49 u.firstPlug(exports.message_confirm, yup, sbot)
50 }}, 'yup')
51
52}
53
54
55

Built with git-ssb-web