Commit 76bc25fbc6edd50d2de53f58f3033960b0b32a34
highlight missing messages in feed and suggest who to follow
Matt McKegg committed on 10/18/2017, 1:27:52 PMParent: 05d0bd7d8358801dc9c1cae96ea29405539a0b84
Files changed
locales/en.json | changed |
modules/feed/html/rollup.js | changed |
modules/message/html/missing.js | added |
modules/page/html/render/message.js | changed |
styles/dark/message.mcss | changed |
styles/light/message.mcss | changed |
locales/en.json | ||
---|---|---|
@@ -170,6 +170,10 @@ | ||
170 | 170 | "However, this person should be able to see your posts.": "However, this person should be able to see your posts.", |
171 | 171 | "However, since they follow someone that follows you, they should be able to see your posts.": "However, since they follow someone that follows you, they should be able to see your posts.", |
172 | 172 | "They might not be able to see your posts either.": "They might not be able to see your posts either.", |
173 | 173 | "However, since you follow someone that follows them, you should be able to see their latest posts.": "However, since you follow someone that follows them, you should be able to see their latest posts.", |
174 | - "An error occured while publishing your message.": "An error occured while publishing your message." | |
174 | + "An error occured while publishing your message.": "An error occured while publishing your message.", | |
175 | + "Missing message": "Missing message", | |
176 | + "The author of this message could be outside of your follow range.": "The author of this message could be outside of your follow range.", | |
177 | + " via ": " via ", | |
178 | + "Cannot load thead": "Cannot load thead" | |
175 | 179 | } |
modules/feed/html/rollup.js | ||
---|---|---|
@@ -17,9 +17,8 @@ | ||
17 | 17 | |
18 | 18 | // bump even for first message |
19 | 19 | var rootBumpTypes = ['mention', 'channel-mention'] |
20 | 20 | |
21 | - | |
22 | 21 | exports.needs = nest({ |
23 | 22 | 'about.obs.name': 'first', |
24 | 23 | 'app.sync.externalHandler': 'first', |
25 | 24 | 'message.html.render': 'first', |
@@ -29,8 +28,9 @@ | ||
29 | 28 | 'feed.pull.rollup': 'first', |
30 | 29 | 'sbot.async.get': 'first', |
31 | 30 | 'keys.sync.id': 'first', |
32 | 31 | 'intl.sync.i18n': 'first', |
32 | + 'message.html.missing': 'first' | |
33 | 33 | }) |
34 | 34 | |
35 | 35 | exports.gives = nest({ |
36 | 36 | 'feed.html.rollup': true |
@@ -179,9 +179,13 @@ | ||
179 | 179 | previousId, |
180 | 180 | priority: highlightItems.has(msg.key) ? 2 : 0 |
181 | 181 | }) |
182 | 182 | previousId = msg.key |
183 | - return result | |
183 | + return [ | |
184 | + // insert missing message marker (if can't be found) | |
185 | + api.message.html.missing(last(msg.value.content.branch), msg), | |
186 | + result | |
187 | + ] | |
184 | 188 | }) |
185 | 189 | |
186 | 190 | var renderedMessage = api.message.html.render(item, { |
187 | 191 | inContext: true, |
@@ -322,4 +326,12 @@ | ||
322 | 326 | |
323 | 327 | function byAssertedTime (a, b) { |
324 | 328 | return a.value.timestamp - b.value.timestamp |
325 | 329 | } |
330 | + | |
331 | +function last (array) { | |
332 | + if (Array.isArray(array)) { | |
333 | + return array[array.length - 1] | |
334 | + } else { | |
335 | + return array | |
336 | + } | |
337 | +} |
modules/message/html/missing.js | ||
---|---|---|
@@ -1,0 +1,45 @@ | ||
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 | + 'intl.sync.i18n': 'first' | |
11 | +}) | |
12 | + | |
13 | +exports.gives = nest('message.html.missing') | |
14 | + | |
15 | +exports.create = function (api) { | |
16 | + const i18n = api.intl.sync.i18n | |
17 | + return nest('message.html.missing', function (id, hintMessage) { | |
18 | + var result = Value() | |
19 | + if (ref.isMsg(id)) { | |
20 | + api.sbot.async.get(id, function (_, value) { | |
21 | + if (!value) { | |
22 | + result.set(messageMissing(id, hintMessage)) | |
23 | + } | |
24 | + }) | |
25 | + } | |
26 | + | |
27 | + return result | |
28 | + }) | |
29 | + | |
30 | + function messageMissing (id, hintMessage) { | |
31 | + return h('Message -missing -reply', [ | |
32 | + h('header', [ | |
33 | + h('div.main', [ | |
34 | + h('div.main', [ | |
35 | + h('div.name', ['⚠️ ', h('strong', i18n('Missing message')), i18n(' via '), api.profile.html.person(hintMessage.value.author)]), | |
36 | + h('div.meta', [h('a', {href: id}, id)]) | |
37 | + ]) | |
38 | + ]) | |
39 | + ]), | |
40 | + h('section', [ | |
41 | + h('p', [i18n(`The author of this message could be outside of your follow range.`)]) | |
42 | + ]) | |
43 | + ]) | |
44 | + } | |
45 | +} |
modules/page/html/render/message.js | ||
---|---|---|
@@ -11,9 +11,10 @@ | ||
11 | 11 | render: 'first', |
12 | 12 | compose: 'first' |
13 | 13 | }, |
14 | 14 | 'sbot.async.get': 'first', |
15 | - 'intl.sync.i18n': 'first' | |
15 | + 'intl.sync.i18n': 'first', | |
16 | + 'message.html.missing': 'first' | |
16 | 17 | }) |
17 | 18 | |
18 | 19 | exports.gives = nest('page.html.render') |
19 | 20 | |
@@ -80,8 +81,9 @@ | ||
80 | 81 | return computed([msg, thread.previousKey(msg)], (msg, previousId) => { |
81 | 82 | return h('div', { |
82 | 83 | hooks: [AnchorHook(msg.key, anchor, showContext)] |
83 | 84 | }, [ |
85 | + msg.key !== id ? api.message.html.missing(last(msg.value.content.branch), msg) : null, | |
84 | 86 | api.message.html.render(msg, { |
85 | 87 | pageId: id, |
86 | 88 | previousId, |
87 | 89 | includeForks: msg.key !== id, |
@@ -134,4 +136,12 @@ | ||
134 | 136 | function isScroller (element) { |
135 | 137 | var value = window.getComputedStyle(element)['overflow-y'] |
136 | 138 | return (value === 'auto' || value === 'scroll') |
137 | 139 | } |
140 | + | |
141 | +function last (array) { | |
142 | + if (Array.isArray(array)) { | |
143 | + return array[array.length - 1] | |
144 | + } else { | |
145 | + return array | |
146 | + } | |
147 | +} |
styles/dark/message.mcss | ||
---|---|---|
@@ -46,8 +46,23 @@ | ||
46 | 46 | } |
47 | 47 | } |
48 | 48 | } |
49 | 49 | |
50 | + -missing { | |
51 | + header { | |
52 | + div.main { | |
53 | + div.main { | |
54 | + margin-left: 0 | |
55 | + } | |
56 | + } | |
57 | + } | |
58 | + section { | |
59 | + font-size: 90% | |
60 | + font-style: italic | |
61 | + color: #777 | |
62 | + } | |
63 | + } | |
64 | + | |
50 | 65 | -reply { |
51 | 66 | header { |
52 | 67 | font-size: 100% |
53 | 68 | div.meta { |
styles/light/message.mcss | ||
---|---|---|
@@ -71,8 +71,23 @@ | ||
71 | 71 | } |
72 | 72 | } |
73 | 73 | } |
74 | 74 | |
75 | + -missing { | |
76 | + header { | |
77 | + div.main { | |
78 | + div.main { | |
79 | + margin-left: 0 | |
80 | + } | |
81 | + } | |
82 | + } | |
83 | + section { | |
84 | + font-size: 90% | |
85 | + font-style: italic | |
86 | + color: #777 | |
87 | + } | |
88 | + } | |
89 | + | |
75 | 90 | -new { |
76 | 91 | box-shadow: 0 0 1px #ffc600; |
77 | 92 | z-index: 1; |
78 | 93 | } |
Built with git-ssb-web