git ssb

0+

alanz / patchwork



forked from Matt McKegg / patchwork

Tree: 077698ae8bb90622236a3a4f224f6251dcb7040b

Files: 077698ae8bb90622236a3a4f224f6251dcb7040b / plugs / message / html / layout / mini.js

1436 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.content
52 ]),
53 h('div.meta', {}, [
54 api.message.html.meta(msg),
55 api.message.html.timestamp(msg),
56 additionalMeta
57 ])
58 ]),
59 footer
60 ])
61 }
62}
63

Built with git-ssb-web