git ssb

7+

dinoworm ๐Ÿ› / patchcore



Tree: cc390daa09626dec00f9649bd2685152e9466432

Files: cc390daa09626dec00f9649bd2685152e9466432 / message / html / render / channel.js

1067 bytesRaw
1var h = require('mutant/h')
2var nest = require('depnest')
3var extend = require('xtend')
4
5exports.needs = nest({
6 'message.html': {
7 decorate: 'reduce',
8 layout: 'first',
9 link: 'first',
10 markdown: 'first'
11 }
12})
13
14exports.gives = nest({
15 'message.html': {
16 canRender: true,
17 render: true
18 }
19})
20
21exports.create = function (api) {
22 return nest('message.html', {
23 canRender: isRenderable,
24 render: channel
25 })
26
27 function channel (msg, opts) {
28 if (!isRenderable(msg)) return
29 var element = api.message.html.layout(msg, extend({
30 content: renderContent(msg),
31 layout: 'mini'
32 }, opts))
33
34 return api.message.html.decorate(element, {
35 msg
36 })
37 }
38
39 function renderContent (msg) {
40 var channel = '#' + msg.value.content.channel
41 return [
42 msg.value.content.subscribed ? 'subscribed to channel' : 'unsubscribed from channel', ' ', h('a.channel', {
43 href: channel
44 }, channel)
45 ]
46 }
47
48 function isRenderable (msg) {
49 return msg.value.content.type === 'channel' ? true : undefined
50 }
51}
52

Built with git-ssb-web