git ssb

7+

dinoworm ๐Ÿ› / patchcore



Tree: f5a00d5cf86de5f3363ef3c52de288cb24586390

Files: f5a00d5cf86de5f3363ef3c52de288cb24586390 / message / html / render / post.js

1208 bytesRaw
1var h = require('mutant/h')
2var nest = require('depnest')
3var extend = require('xtend')
4
5exports.needs = nest({
6 'contact.obs.blockers': 'first',
7 'keys.sync.id': 'first',
8 'message.html': {
9 decorate: 'reduce',
10 layout: 'first',
11 link: 'first',
12 markdown: 'first'
13 }
14})
15
16exports.gives = nest('message.html.render')
17
18exports.create = function (api) {
19 const myId = api.keys.sync.id()
20
21 return nest('message.html.render', function renderMessage (msg, opts) {
22 if (msg.value.content.type !== 'post') return
23
24 const blockers = api.contact.obs.blockers(msg.value.author)
25 if (blockers().includes(myId)) return
26
27 var element = api.message.html.layout(msg, extend({
28 title: messageTitle(msg),
29 content: messageContent(msg),
30 layout: 'default'
31 }, opts))
32
33 return api.message.html.decorate(element, { msg })
34 })
35
36 function messageContent (data) {
37 if (!data.value.content || !data.value.content.text) return
38 return h('div', {}, api.message.html.markdown(data.value.content))
39 }
40
41 function messageTitle (data) {
42 var root = data.value.content && data.value.content.root
43 return !root ? null : h('span', ['re: ', api.message.html.link(root)])
44 }
45}
46

Built with git-ssb-web