git ssb

0+

alanz / patchwork



forked from Matt McKegg / patchwork

Tree: 9e3d2a27287664a8a12ac78c22384a9748102890

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

978 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 'profile.html.person': 'first'
12})
13
14exports.gives = nest('message.html.render')
15
16exports.create = function (api) {
17 return nest('message.html.render', function renderMessage (msg, opts) {
18 if (msg.value.content.type !== 'contact') return
19 if (!ref.isFeed(msg.value.content.contact)) return
20 if (typeof msg.value.content.following !== 'boolean') return
21
22 var element = api.message.html.layout(msg, extend({
23 miniContent: messageContent(msg),
24 layout: 'mini'
25 }, opts))
26
27 return api.message.html.decorate(element, { msg })
28 })
29
30 function messageContent (msg) {
31 var following = msg.value.content.following
32 return [
33 following ? 'followed ' : 'unfollowed ',
34 api.profile.html.person(msg.value.content.contact)
35 ]
36 }
37}
38

Built with git-ssb-web