git ssb

0+

alanz / patchwork



forked from Matt McKegg / patchwork

Commit 8b4e456e87cad1c31bf2022137e937fe3a47c2ad

experimental "reply to" tracking for resolving missing message authors

Matt McKegg committed on 11/4/2017, 11:19:11 PM
Parent: 3a3732c95a5d34d4a8f506224643609f35c55a5d

Files changed

lib/context-menu-and-spellcheck.jschanged
locales/en.jsonchanged
modules/message/html/missing.jschanged
modules/page/html/render/message.jschanged
lib/context-menu-and-spellcheck.jsView
@@ -98,9 +98,9 @@
9898 click: function () {
9999 clipboard.writeText(element.msg.key)
100100 }
101101 }))
102- if (element.msg.value.content.text) {
102+ if (element.msg.value.content && element.msg.value.content.text) {
103103 menu.append(new MenuItem({
104104 label: 'Copy Message Text',
105105 click: function () {
106106 clipboard.writeText(element.msg.value.content.text)
locales/en.jsonView
@@ -181,6 +181,7 @@
181181 },
182182 "Followed by": "Followed by",
183183 "pt-BR": "Brazillian Portuguese",
184184 "See less": "See less",
185- "See more": "See more"
185+ "See more": "See more",
186+ "(missing message)": "(missing message)"
186187 }
modules/message/html/missing.jsView
@@ -1,6 +1,7 @@
11 var h = require('mutant/h')
22 var Value = require('mutant/value')
3+var when = require('mutant/when')
34 var ref = require('ssb-ref')
45
56 var nest = require('depnest')
67
@@ -28,22 +29,46 @@
2829 return result
2930 })
3031
3132 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', [
3342 h('header', [
3443 h('div.main', [
3544 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)]),
3751 h('div.meta', [h('a', {href: id}, id)])
3852 ])
3953 ]),
4054 h('div.meta', [
41- api.message.html.meta({key: id, value: {missing: true}})
55+ api.message.html.meta(msg)
4256 ])
4357 ]),
4458 h('section', [
4559 h('p', [i18n(`The author of this message could be outside of your follow range or they may be blocked.`)])
4660 ])
4761 ])
62+
63+ element.msg = msg
64+ return element
4865 }
4966 }
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.jsView
@@ -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')
22 var nest = require('depnest')
33 var ref = require('ssb-ref')
44 var AnchorHook = require('../../../../lib/anchor-hook')
55
@@ -31,8 +31,9 @@
3131 var meta = Struct({
3232 type: 'post',
3333 root: Proxy(id),
3434 branch: Proxy(id),
35+ reply: Value(undefined),
3536 channel: Value(undefined),
3637 recps: Value(undefined)
3738 })
3839
@@ -65,8 +66,9 @@
6566
6667 // what happens in private stays in private!
6768 meta.recps.set(value.content.recps)
6869
70+ var author = value.author
6971 var root = api.message.sync.root({key: id, value}) || id
7072 var isReply = id !== root
7173 var thread = api.feed.obs.thread(id, {branch: isReply})
7274
@@ -100,8 +102,16 @@
100102 ]),
101103 compose
102104 ])
103105 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+ })
104114 })
105115
106116 var view = h('div', {className: 'SplitView'}, [
107117 h('div.main', [

Built with git-ssb-web