git ssb

16+

Dominic / patchbay



Tree: 0317853c50ffacda585e8b019f18d3b8ff32329a

Files: 0317853c50ffacda585e8b019f18d3b8ff32329a / modules / message.js

1252 bytesRaw
1var h = require('hyperscript')
2var u = require('../util')
3var pull = require('pull-stream')
4
5exports.message_render = function (msg, sbot) {
6 var el = u.firstPlug(exports.message_content, msg, sbot)
7
8 function map (plugs, value) {
9 return plugs.map(function (plug) {
10 return plug(value, sbot)
11 }).filter(Boolean)
12 }
13
14 var backlinks = h('div.backlinks')
15
16 pull(
17 sbot.links({dest: msg.key, rel: 'mentions', keys: true}),
18 pull.collect(function (err, links) {
19 if(links.length)
20 backlinks.appendChild(h('label', 'backlinks:',
21 h('div', links.map(function (link) {
22 return u.decorate(exports.message_link, link.key, function (d, e, v) { return d(e, v, sbot) })
23 }))
24 ))
25 })
26 )
27
28 if(el)
29 return h('div.message.column',
30 h('div.title.row',
31 h('div.avatar', map(exports.avatar, msg.value.author)),
32 h('div.message_meta.row', map(exports.message_meta, msg))
33 ),
34 h('div.message_content', el),
35 h('div.message_actions.row',
36 h('div.actions', map(exports.message_action, msg))
37 ),
38 backlinks
39 )
40}
41
42exports.message_content = []
43exports.avatar = []
44exports.message_meta = []
45exports.message_action = []
46exports.message_link = []
47
48

Built with git-ssb-web