git ssb

1+

Daan Patchwork / patchwork



Tree: b6d7ee34ab7b57861dd88fc633ba98bfb721b099

Files: b6d7ee34ab7b57861dd88fc633ba98bfb721b099 / lib / depject / message / html / missing.js

1647 bytesRaw
1const h = require('mutant/h')
2const computed = require('mutant/computed')
3const ref = require('ssb-ref')
4
5const nest = require('depnest')
6
7exports.needs = nest({
8 'message.obs.get': 'first',
9 'profile.html.person': 'first',
10 'message.html.metas': 'first',
11 'intl.sync.i18n': 'first'
12})
13
14exports.gives = nest('message.html.missing')
15
16exports.create = function (api) {
17 const i18n = api.intl.sync.i18n
18 return nest('message.html.missing', function (id, hintMessage) {
19 if (!ref.isMsg(id)) return
20 const msg = api.message.obs.get(id, hintMessage)
21 return computed(msg, msg => {
22 if (msg && msg.value && msg.value.missing) {
23 // TODO: handle out-of-order resolved message, or message resolved later
24 return messageMissing(msg, hintMessage)
25 }
26 })
27 })
28
29 function messageMissing (msg, hintMessage) {
30 const element = h('Message -missing -reply', [
31 h('header', [
32 h('div.main', [
33 h('div.main', [
34 h('div.name', [
35 '⚠️ ',
36 msg.value.author
37 ? [api.profile.html.person(msg.value.author), ' ', i18n('(missing message)')]
38 : h('strong', i18n('Missing message')),
39 i18n(' via '), api.profile.html.person(hintMessage.value.author)]),
40 h('div.meta', [h('a', { href: msg.key }, msg.key)])
41 ])
42 ]),
43 h('div.meta', [
44 api.message.html.metas(msg)
45 ])
46 ]),
47 h('section', [
48 h('p', [i18n('The author of this message could be outside of your follow range or they may be blocked.')])
49 ])
50 ])
51
52 element.msg = msg
53 return element
54 }
55}
56

Built with git-ssb-web