Commit 2f61b5b3290364b166a9c8fe8deaa025e501e8b9
add follow rendering
mix irving committed on 4/2/2017, 11:18:30 AMParent: cfe9ce7cf96f4027441c0d3ce54ead220a5018b1
Files changed
main/sync/catch-keyboard-shortcut.js | changed |
message/html/render/follow.js | added |
main/sync/catch-keyboard-shortcut.js | ||
---|---|---|
@@ -108,9 +108,9 @@ | ||
108 | 108 | if (msg === undefined) return setTimeout(locateKey, 100) |
109 | 109 | |
110 | 110 | if (msg && msg.dataset && msg.dataset.key === key) return |
111 | 111 | |
112 | - locateKey () | |
112 | + locateKey() | |
113 | 113 | } |
114 | 114 | } |
115 | 115 | |
116 | 116 | function toggleRawMessage (ev) { |
message/html/render/follow.js | ||
---|---|---|
@@ -1,0 +1,37 @@ | ||
1 | +const nest = require('depnest') | |
2 | +const extend = require('xtend') | |
3 | + | |
4 | +exports.gives = nest('message.html.render') | |
5 | + | |
6 | +exports.needs = nest({ | |
7 | + 'about.html.link': 'first', | |
8 | + 'message.html': { | |
9 | + decorate: 'reduce', | |
10 | + layout: 'first' | |
11 | + } | |
12 | +}) | |
13 | + | |
14 | +exports.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 | + |
Built with git-ssb-web