Commit 8b4e456e87cad1c31bf2022137e937fe3a47c2ad
experimental "reply to" tracking for resolving missing message authors
Matt McKegg committed on 11/4/2017, 11:19:11 PMParent: 3a3732c95a5d34d4a8f506224643609f35c55a5d
Files changed
lib/context-menu-and-spellcheck.js | changed |
locales/en.json | changed |
modules/message/html/missing.js | changed |
modules/page/html/render/message.js | changed |
lib/context-menu-and-spellcheck.js | ||
---|---|---|
@@ -98,9 +98,9 @@ | ||
98 | 98 | click: function () { |
99 | 99 | clipboard.writeText(element.msg.key) |
100 | 100 | } |
101 | 101 | })) |
102 | - if (element.msg.value.content.text) { | |
102 | + if (element.msg.value.content && element.msg.value.content.text) { | |
103 | 103 | menu.append(new MenuItem({ |
104 | 104 | label: 'Copy Message Text', |
105 | 105 | click: function () { |
106 | 106 | clipboard.writeText(element.msg.value.content.text) |
locales/en.json | ||
---|---|---|
@@ -181,6 +181,7 @@ | ||
181 | 181 | }, |
182 | 182 | "Followed by": "Followed by", |
183 | 183 | "pt-BR": "Brazillian Portuguese", |
184 | 184 | "See less": "See less", |
185 | - "See more": "See more" | |
185 | + "See more": "See more", | |
186 | + "(missing message)": "(missing message)" | |
186 | 187 | } |
modules/message/html/missing.js | ||
---|---|---|
@@ -1,6 +1,7 @@ | ||
1 | 1 | var h = require('mutant/h') |
2 | 2 | var Value = require('mutant/value') |
3 | +var when = require('mutant/when') | |
3 | 4 | var ref = require('ssb-ref') |
4 | 5 | |
5 | 6 | var nest = require('depnest') |
6 | 7 | |
@@ -28,22 +29,46 @@ | ||
28 | 29 | return result |
29 | 30 | }) |
30 | 31 | |
31 | 32 | function messageMissing (id, hintMessage) { |
32 | - return h('Message -missing -reply', [ | |
33 | + var possibleAuthor = only(hintMessage.value.content.reply) | |
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', [ | |
33 | 42 | h('header', [ |
34 | 43 | h('div.main', [ |
35 | 44 | h('div.main', [ |
36 | - h('div.name', ['⚠️ ', h('strong', i18n('Missing message')), i18n(' via '), api.profile.html.person(hintMessage.value.author)]), | |
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)]), | |
37 | 51 | h('div.meta', [h('a', {href: id}, id)]) |
38 | 52 | ]) |
39 | 53 | ]), |
40 | 54 | h('div.meta', [ |
41 | - api.message.html.meta({key: id, value: {missing: true}}) | |
55 | + api.message.html.meta(msg) | |
42 | 56 | ]) |
43 | 57 | ]), |
44 | 58 | h('section', [ |
45 | 59 | h('p', [i18n(`The author of this message could be outside of your follow range or they may be blocked.`)]) |
46 | 60 | ]) |
47 | 61 | ]) |
62 | + | |
63 | + element.msg = msg | |
64 | + return element | |
48 | 65 | } |
49 | 66 | } |
67 | + | |
68 | +function only (arrayOrString) { | |
69 | + if (Array.isArray(arrayOrString) && arrayOrString.length === 1) { | |
70 | + return arrayOrString[0] | |
71 | + } else if (typeof arrayOrString === 'string') { | |
72 | + return arrayOrString | |
73 | + } | |
74 | +} |
modules/page/html/render/message.js | ||
---|---|---|
@@ -1,5 +1,5 @@ | ||
1 | -var { h, when, map, Proxy, Struct, Value, computed } = require('mutant') | |
1 | +var { h, when, map, Proxy, Struct, Value, computed, watch } = require('mutant') | |
2 | 2 | var nest = require('depnest') |
3 | 3 | var ref = require('ssb-ref') |
4 | 4 | var AnchorHook = require('../../../../lib/anchor-hook') |
5 | 5 | |
@@ -31,8 +31,9 @@ | ||
31 | 31 | var meta = Struct({ |
32 | 32 | type: 'post', |
33 | 33 | root: Proxy(id), |
34 | 34 | branch: Proxy(id), |
35 | + reply: Value(undefined), | |
35 | 36 | channel: Value(undefined), |
36 | 37 | recps: Value(undefined) |
37 | 38 | }) |
38 | 39 | |
@@ -65,8 +66,9 @@ | ||
65 | 66 | |
66 | 67 | // what happens in private stays in private! |
67 | 68 | meta.recps.set(value.content.recps) |
68 | 69 | |
70 | + var author = value.author | |
69 | 71 | var root = api.message.sync.root({key: id, value}) || id |
70 | 72 | var isReply = id !== root |
71 | 73 | var thread = api.feed.obs.thread(id, {branch: isReply}) |
72 | 74 | |
@@ -100,8 +102,16 @@ | ||
100 | 102 | ]), |
101 | 103 | compose |
102 | 104 | ]) |
103 | 105 | result.set(when(thread.sync, container, loader)) |
106 | + | |
107 | + watch(anchor, (anchor) => { | |
108 | + if (anchor === 'reply') { | |
109 | + meta.reply.set([author]) | |
110 | + } else { | |
111 | + meta.reply.set(undefined) | |
112 | + } | |
113 | + }) | |
104 | 114 | }) |
105 | 115 | |
106 | 116 | var view = h('div', {className: 'SplitView'}, [ |
107 | 117 | h('div.main', [ |
Built with git-ssb-web