git ssb

10+

Matt McKegg / patchwork



Tree: b4f7e1f1954f0a78cb2756b3c39fe7d58881dc43

Files: b4f7e1f1954f0a78cb2756b3c39fe7d58881dc43 / plugs / message / html / layout / mini.js

1476 bytesRaw
1const {h, computed} = require('mutant')
2const nest = require('depnest')
3var ref = require('ssb-ref')
4
5exports.needs = nest({
6 'message.html': {
7 action: 'map',
8 backlinks: 'first',
9 author: 'first',
10 meta: 'map',
11 timestamp: 'first'
12 },
13 'profile.html.person': 'first'
14})
15
16exports.gives = nest('message.html.layout')
17
18exports.create = (api) => {
19 return nest('message.html.layout', mini)
20
21 function mini (msg, opts) {
22 if (opts.layout !== 'mini') return
23
24 var classList = []
25 var additionalMeta = []
26 var footer = []
27
28 if (opts.showActions) {
29 // HACK: this is used for about messages, which really should have there own layout
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
43 if (opts.priority >= 2) {
44 classList.push('-new')
45 additionalMeta.push(h('span.flag -new', {title: 'New Message'}))
46 }
47 return h('Message -mini', {classList}, [
48 h('header', [
49 h('div.mini', [
50 api.profile.html.person(msg.value.author), ' ',
51 opts.miniContent
52 ]),
53 h('div.meta', {}, [
54 api.message.html.meta(msg),
55 api.message.html.timestamp(msg),
56 additionalMeta
57 ])
58 ]),
59 h('section', [opts.content]),
60 footer
61 ])
62 }
63}
64

Built with git-ssb-web