git ssb

10+

Matt McKegg / patchwork



Commit 928d71a15ac1e455b0ce433ef97315727579d131

render channel subscriptions

Matt McKegg committed on 2/15/2017, 3:12:21 PM
Parent: 66eb3aded58d22467d641cb52da1353212e8219a

Files changed

plugs/message/html/render/channel.jsadded
plugs/message/html/render/channel.jsView
@@ -1,0 +1,33 @@
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 +}

Built with git-ssb-web