git ssb

10+

Matt McKegg / patchwork



Tree: e5ad753b8414d998113f9305e0826f4cf1035fe4

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

946 bytesRaw
1var h = require('mutant/h')
2var nest = require('depnest')
3var extend = require('xtend')
4var appRoot = require('app-root-path');
5var i18n = require(appRoot + '/lib/i18n').i18n
6
7exports.needs = nest({
8 'message.html': {
9 decorate: 'reduce',
10 layout: 'first'
11 }
12})
13
14exports.gives = nest('message.html.render')
15
16exports.create = function (api) {
17 return nest('message.html.render', function renderMessage (msg, opts) {
18 if (msg.value.content.type !== 'channel') return
19 var element = api.message.html.layout(msg, extend({
20 miniContent: messageContent(msg),
21 layout: 'mini'
22 }, opts))
23
24 return api.message.html.decorate(element, { msg })
25 })
26
27 function messageContent (msg) {
28 var channel = `#${msg.value.content.channel}`
29 var subscribed = msg.value.content.subscribed
30 return [
31 subscribed ? i18n.__('subscribed to ') : i18n.__('unsubscribed from '),
32 h('a', {href: channel}, channel)
33 ]
34 }
35}
36

Built with git-ssb-web