Files: d03a610c77cee73a156ebe6e4fc1f7369d27fe9d / modules / message / html / missing.js
1332 bytesRaw
1 | var h = require('mutant/h') |
2 | var Value = require('mutant/value') |
3 | var ref = require('ssb-ref') |
4 | |
5 | var nest = require('depnest') |
6 | |
7 | exports.needs = nest({ |
8 | 'sbot.async.get': 'first', |
9 | 'profile.html.person': 'first', |
10 | 'message.html.meta': 'first', |
11 | 'intl.sync.i18n': 'first' |
12 | }) |
13 | |
14 | exports.gives = nest('message.html.missing') |
15 | |
16 | exports.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