git ssb

10+

Matt McKegg / patchwork



Tree: e836f599f0095c03c6bb4b228c714e7130f797f6

Files: e836f599f0095c03c6bb4b228c714e7130f797f6 / plugs / message / html / render / following.js

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

Built with git-ssb-web