git ssb

16+

Dominic / patchbay



Tree: f75c375b21d89dd23dc44b36322462d72c139829

Files: f75c375b21d89dd23dc44b36322462d72c139829 / message / html / render / follow.js

785 bytesRaw
1const nest = require('depnest')
2const extend = require('xtend')
3
4exports.gives = nest('message.html.render')
5
6exports.needs = nest({
7 'about.html.link': 'first',
8 'message.html': {
9 decorate: 'reduce',
10 layout: 'first'
11 }
12})
13
14exports.create = function (api) {
15 return nest('message.html.render', follow)
16
17 function follow (msg, opts) {
18 if (msg.value.content.type !== 'contact') return
19
20 const element = api.message.html.layout(msg, extend({
21 content: renderContent(msg),
22 layout: 'mini'
23 }, opts))
24
25 return api.message.html.decorate(element, { msg })
26 }
27
28 function renderContent (msg) {
29 const { contact, following } = msg.value.content
30
31 return [
32 following ? 'followed ' : 'unfollowed ',
33 api.about.html.link(contact)
34 ]
35 }
36}
37
38

Built with git-ssb-web