plugs/message/html/layout/mini.jsView |
---|
1 | | -const h = require('mutant/h') |
| 1 | +const {h, computed} = require('mutant') |
2 | 2 | const nest = require('depnest') |
| 3 | +var ref = require('ssb-ref') |
3 | 4 | |
4 | 5 | exports.needs = nest({ |
5 | 6 | 'message.html': { |
| 7 | + action: 'map', |
6 | 8 | backlinks: 'first', |
7 | 9 | author: 'first', |
8 | 10 | meta: 'map', |
9 | 11 | timestamp: 'first' |
16 | 18 | exports.create = (api) => { |
17 | 19 | return nest('message.html.layout', mini) |
18 | 20 | |
19 | 21 | function mini (msg, opts) { |
| 22 | + if (opts.layout !== 'mini') return |
| 23 | + |
20 | 24 | var classList = [] |
21 | 25 | var additionalMeta = [] |
| 26 | + var footer = [] |
| 27 | + |
| 28 | + if (opts.showActions) { |
| 29 | + |
| 30 | + footer.push( |
| 31 | + computed(msg.key, (key) => { |
| 32 | + if (ref.isMsg(key)) { |
| 33 | + return h('footer', [ |
| 34 | + h('div.actions', [ |
| 35 | + api.message.html.action(msg) |
| 36 | + ]) |
| 37 | + ]) |
| 38 | + } |
| 39 | + }) |
| 40 | + ) |
| 41 | + } |
| 42 | + |
22 | 43 | if (opts.priority >= 2) { |
23 | 44 | classList.push('-new') |
24 | 45 | additionalMeta.push(h('span.flag -new', {title: 'New Message'})) |
25 | 46 | } |
26 | | - if (opts.layout !== 'mini') return |
27 | 47 | return h('Message -mini', {classList}, [ |
28 | 48 | h('header', [ |
29 | 49 | h('div.mini', [ |
30 | 50 | api.profile.html.person(msg.value.author), ' ', |
31 | 51 | opts.content |
32 | 52 | ]), |
33 | 53 | h('div.meta', {}, [ |
| 54 | + api.message.html.meta(msg), |
34 | 55 | api.message.html.timestamp(msg), |
35 | 56 | additionalMeta |
36 | 57 | ]) |
37 | | - ]) |
| 58 | + ]), |
| 59 | + footer |
38 | 60 | ]) |
39 | 61 | } |
40 | 62 | } |