Files: b4f7e1f1954f0a78cb2756b3c39fe7d58881dc43 / plugs / message / html / render / channel.js
837 bytesRaw
1 | var h = require('mutant/h') |
2 | var nest = require('depnest') |
3 | var extend = require('xtend') |
4 | |
5 | exports.needs = nest({ |
6 | 'message.html': { |
7 | decorate: 'reduce', |
8 | layout: 'first' |
9 | } |
10 | }) |
11 | |
12 | exports.gives = nest('message.html.render') |
13 | |
14 | exports.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