git ssb

10+

Matt McKegg / patchwork



Tree: c38545a2f64b06e7150cd79d548831b8b753c405

Files: c38545a2f64b06e7150cd79d548831b8b753c405 / plugs / message / html / render / channel.js

837 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 }
10})
11
12exports.gives = nest('message.html.render')
13
14exports.create = function (api) {
15 return nest('message.html.render', function renderMessage (msg, opts) {
16 if (msg.value.content.type !== 'channel') return
17 var element = api.message.html.layout(msg, extend({
18 content: messageContent(msg),
19 layout: 'mini'
20 }, opts))
21
22 return api.message.html.decorate(element, { msg })
23 })
24
25 function messageContent (msg) {
26 var channel = `#${msg.value.content.channel}`
27 var subscribed = msg.value.content.subscribed
28 return [
29 subscribed ? 'subscribed to ' : 'unsubscribed from ',
30 h('a', {href: channel}, channel)
31 ]
32 }
33}
34

Built with git-ssb-web