git ssb

1+

Daan Patchwork / patchwork



Tree: 3451510316992d414ec76ba5b29681fe359b7428

Files: 3451510316992d414ec76ba5b29681fe359b7428 / lib / depject / message / html / render / issue.js

1017 bytesRaw
1const h = require('mutant/h')
2const nest = require('depnest')
3const extend = require('xtend')
4const addContextMenu = require('../../../../message/html/decorate/context-menu')
5
6exports.needs = nest({
7 'message.html': {
8 layout: 'first',
9 markdown: 'first'
10 }
11})
12
13exports.gives = nest({
14 'message.html': {
15 canRender: true,
16 render: true
17 }
18})
19
20exports.create = function (api) {
21 return nest('message.html', {
22 canRender: isRenderable,
23 render: function (msg, opts) {
24 if (!isRenderable(msg)) return
25 const element = api.message.html.layout(msg, extend({
26 content: messageContent(msg),
27 layout: 'default'
28 }, opts))
29
30 return addContextMenu(element, {
31 msg
32 })
33 }
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 isRenderable (msg) {
42 return msg.value.content.type === 'issue' ? true : undefined
43 }
44}
45

Built with git-ssb-web