git ssb

0+

alanz / patchwork



forked from Matt McKegg / patchwork

Tree: 77e7fa628b43035fa4c24ea1a9eb35529874721d

Files: 77e7fa628b43035fa4c24ea1a9eb35529874721d / plugs / message / html / render / channel.js

916 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 'intl.sync.i18n':'first',
11})
12
13exports.gives = nest('message.html.render')
14
15exports.create = function (api) {
16 const i18n = api.intl.sync.i18n
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