git ssb

0+

alanz / patchwork



forked from Matt McKegg / patchwork

Commit 76bc25fbc6edd50d2de53f58f3033960b0b32a34

highlight missing messages in feed and suggest who to follow

Matt McKegg committed on 10/18/2017, 1:27:52 PM
Parent: 05d0bd7d8358801dc9c1cae96ea29405539a0b84

Files changed

locales/en.jsonchanged
modules/feed/html/rollup.jschanged
modules/message/html/missing.jsadded
modules/page/html/render/message.jschanged
styles/dark/message.mcsschanged
styles/light/message.mcsschanged
locales/en.jsonView
@@ -170,6 +170,10 @@
170170 "However, this person should be able to see your posts.": "However, this person should be able to see your posts.",
171171 "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.",
172172 "They might not be able to see your posts either.": "They might not be able to see your posts either.",
173173 "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"
175179 }
modules/feed/html/rollup.jsView
@@ -17,9 +17,8 @@
1717
1818 // bump even for first message
1919 var rootBumpTypes = ['mention', 'channel-mention']
2020
21-
2221 exports.needs = nest({
2322 'about.obs.name': 'first',
2423 'app.sync.externalHandler': 'first',
2524 'message.html.render': 'first',
@@ -29,8 +28,9 @@
2928 'feed.pull.rollup': 'first',
3029 'sbot.async.get': 'first',
3130 'keys.sync.id': 'first',
3231 'intl.sync.i18n': 'first',
32+ 'message.html.missing': 'first'
3333 })
3434
3535 exports.gives = nest({
3636 'feed.html.rollup': true
@@ -179,9 +179,13 @@
179179 previousId,
180180 priority: highlightItems.has(msg.key) ? 2 : 0
181181 })
182182 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+ ]
184188 })
185189
186190 var renderedMessage = api.message.html.render(item, {
187191 inContext: true,
@@ -322,4 +326,12 @@
322326
323327 function byAssertedTime (a, b) {
324328 return a.value.timestamp - b.value.timestamp
325329 }
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.jsView
@@ -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.jsView
@@ -11,9 +11,10 @@
1111 render: 'first',
1212 compose: 'first'
1313 },
1414 'sbot.async.get': 'first',
15- 'intl.sync.i18n': 'first'
15+ 'intl.sync.i18n': 'first',
16+ 'message.html.missing': 'first'
1617 })
1718
1819 exports.gives = nest('page.html.render')
1920
@@ -80,8 +81,9 @@
8081 return computed([msg, thread.previousKey(msg)], (msg, previousId) => {
8182 return h('div', {
8283 hooks: [AnchorHook(msg.key, anchor, showContext)]
8384 }, [
85+ msg.key !== id ? api.message.html.missing(last(msg.value.content.branch), msg) : null,
8486 api.message.html.render(msg, {
8587 pageId: id,
8688 previousId,
8789 includeForks: msg.key !== id,
@@ -134,4 +136,12 @@
134136 function isScroller (element) {
135137 var value = window.getComputedStyle(element)['overflow-y']
136138 return (value === 'auto' || value === 'scroll')
137139 }
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.mcssView
@@ -46,8 +46,23 @@
4646 }
4747 }
4848 }
4949
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+
5065 -reply {
5166 header {
5267 font-size: 100%
5368 div.meta {
styles/light/message.mcssView
@@ -71,8 +71,23 @@
7171 }
7272 }
7373 }
7474
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+
7590 -new {
7691 box-shadow: 0 0 1px #ffc600;
7792 z-index: 1;
7893 }

Built with git-ssb-web