Files: e5ad753b8414d998113f9305e0826f4cf1035fe4 / plugs / message / html / render / following.js
1083 bytesRaw
1 | var h = require('mutant/h') |
2 | var nest = require('depnest') |
3 | var extend = require('xtend') |
4 | var ref = require('ssb-ref') |
5 | var appRoot = require('app-root-path'); |
6 | var i18n = require(appRoot + '/lib/i18n').i18n |
7 | |
8 | exports.needs = nest({ |
9 | 'message.html': { |
10 | decorate: 'reduce', |
11 | layout: 'first' |
12 | }, |
13 | 'profile.html.person': 'first' |
14 | }) |
15 | |
16 | exports.gives = nest('message.html.render') |
17 | |
18 | exports.create = function (api) { |
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