git ssb

0+

alanz / patchwork



forked from Matt McKegg / patchwork

Tree: 9e3d2a27287664a8a12ac78c22384a9748102890

Files: 9e3d2a27287664a8a12ac78c22384a9748102890 / plugs / message / html / render / attending.js

1040 bytesRaw
1var h = require('mutant/h')
2var nest = require('depnest')
3var extend = require('xtend')
4var ref = require('ssb-ref')
5
6exports.needs = nest({
7 'message.html': {
8 decorate: 'reduce',
9 layout: 'first'
10 },
11 'about.obs.latestValue': 'first'
12})
13
14exports.gives = nest('message.html.render')
15
16exports.create = function (api) {
17 return nest('message.html.render', function about (msg, opts) {
18 if (msg.value.content.type !== 'about') return
19 if (!ref.isMsg(msg.value.content.about)) return
20 if (!msg.value.content.attendee) return
21 if (msg.value.content.attendee.link !== msg.value.author) return
22
23 var action = msg.value.content.attendee.remove ? `can't attend` : 'is attending'
24 var target = msg.value.content.about
25 var title = api.about.obs.latestValue(target, 'title')
26 var element = api.message.html.layout(msg, extend({
27 showActions: true,
28 miniContent: [action, ' ', h('a', {href: target}, title)],
29 layout: 'mini'
30 }, opts))
31
32 return api.message.html.decorate(element, { msg })
33 })
34}
35

Built with git-ssb-web