git ssb

10+

Matt McKegg / patchwork



Tree: bdee82e994ee3ce0e26e552ad2fba8393f32ce45

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

1332 bytesRaw
1var h = require('mutant/h')
2var Value = require('mutant/value')
3var ref = require('ssb-ref')
4
5var nest = require('depnest')
6
7exports.needs = nest({
8 'sbot.async.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 var result = Value()
20 if (ref.isMsg(id)) {
21 api.sbot.async.get(id, function (_, value) {
22 if (!value) {
23 result.set(messageMissing(id, hintMessage))
24 }
25 })
26 }
27
28 return result
29 })
30
31 function messageMissing (id, hintMessage) {
32 return h('Message -missing -reply', [
33 h('header', [
34 h('div.main', [
35 h('div.main', [
36 h('div.name', ['⚠️ ', h('strong', i18n('Missing message')), i18n(' via '), api.profile.html.person(hintMessage.value.author)]),
37 h('div.meta', [h('a', {href: id}, id)])
38 ])
39 ]),
40 h('div.meta', [
41 api.message.html.meta({key: id, value: {missing: true}})
42 ])
43 ]),
44 h('section', [
45 h('p', [i18n(`The author of this message could be outside of your follow range or they may be blocked.`)])
46 ])
47 ])
48 }
49}
50

Built with git-ssb-web