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