git ssb

0+

alanz / patchwork



forked from Matt McKegg / patchwork

Tree: 7cda75eab5c68ce985a6dd1154a45acc301b29ec

Files: 7cda75eab5c68ce985a6dd1154a45acc301b29ec / modules / message / html / missing.js

1631 bytesRaw
1var h = require('mutant/h')
2var computed = require('mutant/computed')
3var ref = require('ssb-ref')
4
5var nest = require('depnest')
6
7exports.needs = nest({
8 'message.obs.get': 'first',
9 'profile.html.person': 'first',
10 'message.html.meta': '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 var 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 var 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.meta(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