Files: f98587b805da63c46cc6810f870c08e333ff5f4d / plugs / message / html / render / channel.js
916 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 | 'intl.sync.i18n':'first', |
11 | }) |
12 | |
13 | exports.gives = nest('message.html.render') |
14 | |
15 | exports.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