git ssb

0+

alanz / patchwork



forked from Matt McKegg / patchwork

Tree: b430a48e8147ce78ad7562695d9d54153e308fca

Files: b430a48e8147ce78ad7562695d9d54153e308fca / modules / message / html / missing.js

1803 bytesRaw
1var h = require('mutant/h')
2var Value = require('mutant/value')
3var when = require('mutant/when')
4var ref = require('ssb-ref')
5
6var nest = require('depnest')
7
8exports.needs = nest({
9 'sbot.async.get': 'first',
10 'profile.html.person': 'first',
11 'message.html.meta': 'first',
12 'intl.sync.i18n': 'first'
13})
14
15exports.gives = nest('message.html.missing')
16
17exports.create = function (api) {
18 const i18n = api.intl.sync.i18n
19 return nest('message.html.missing', function (id, hintMessage) {
20 var result = Value()
21 if (ref.isMsg(id)) {
22 api.sbot.async.get(id, function (_, value) {
23 if (!value) {
24 result.set(messageMissing(id, hintMessage))
25 }
26 })
27 }
28
29 return result
30 })
31
32 function messageMissing (id, hintMessage) {
33 var possibleAuthor = hintMessage.value.content.reply && hintMessage.value.content.reply[id]
34 var msg = {
35 key: id,
36 value: {
37 missing: true,
38 author: ref.isFeed(possibleAuthor) ? possibleAuthor : null
39 }
40 }
41 var element = h('Message -missing -reply', [
42 h('header', [
43 h('div.main', [
44 h('div.main', [
45 h('div.name', [
46 '⚠️ ',
47 msg.value.author
48 ? [api.profile.html.person(msg.value.author), ' ', i18n('(missing message)')]
49 : h('strong', i18n('Missing message')),
50 i18n(' via '), api.profile.html.person(hintMessage.value.author)]),
51 h('div.meta', [h('a', {href: id}, id)])
52 ])
53 ]),
54 h('div.meta', [
55 api.message.html.meta(msg)
56 ])
57 ]),
58 h('section', [
59 h('p', [i18n(`The author of this message could be outside of your follow range or they may be blocked.`)])
60 ])
61 ])
62
63 element.msg = msg
64 return element
65 }
66}
67

Built with git-ssb-web