Permalink
Browse files

experimental "reply to" tracking for resolving missing message authors

  • Loading branch information...
mmckegg committed Nov 4, 2017
1 parent 3a3732c commit 8b4e456e87cad1c31bf2022137e937fe3a47c2ad
Showing with 42 additions and 6 deletions.
  1. +1 −1 lib/context-menu-and-spellcheck.js
  2. +2 −1 locales/en.json
  3. +28 −3 modules/message/html/missing.js
  4. +11 −1 modules/page/html/render/message.js
@@ -99,7 +99,7 @@ function setupContextMenuAndSpellCheck (config) {
clipboard.writeText(element.msg.key)
}
}))
if (element.msg.value.content.text) {
if (element.msg.value.content && element.msg.value.content.text) {
menu.append(new MenuItem({
label: 'Copy Message Text',
click: function () {
View
@@ -182,5 +182,6 @@
"Followed by": "Followed by",
"pt-BR": "Brazillian Portuguese",
"See less": "See less",
"See more": "See more"
"See more": "See more",
"(missing message)": "(missing message)"
}
@@ -1,5 +1,6 @@
var h = require('mutant/h')
var Value = require('mutant/value')
var when = require('mutant/when')
var ref = require('ssb-ref')
var nest = require('depnest')
@@ -29,21 +30,45 @@ exports.create = function (api) {
})
function messageMissing (id, hintMessage) {
return h('Message -missing -reply', [
var possibleAuthor = only(hintMessage.value.content.reply)
var msg = {
key: id,
value: {
missing: true,
author: ref.isFeed(possibleAuthor) ? possibleAuthor : null
}
}
var element = h('Message -missing -reply', [
h('header', [
h('div.main', [
h('div.main', [
h('div.name', ['⚠️ ', h('strong', i18n('Missing message')), i18n(' via '), api.profile.html.person(hintMessage.value.author)]),
h('div.name', [
'⚠️ ',
msg.value.author
? [api.profile.html.person(msg.value.author), ' ', i18n('(missing message)')]
: h('strong', i18n('Missing message')),
i18n(' via '), api.profile.html.person(hintMessage.value.author)]),
h('div.meta', [h('a', {href: id}, id)])
])
]),
h('div.meta', [
api.message.html.meta({key: id, value: {missing: true}})
api.message.html.meta(msg)
])
]),
h('section', [
h('p', [i18n(`The author of this message could be outside of your follow range or they may be blocked.`)])
])
])
element.msg = msg
return element
}
}
function only (arrayOrString) {
if (Array.isArray(arrayOrString) && arrayOrString.length === 1) {
return arrayOrString[0]
} else if (typeof arrayOrString === 'string') {
return arrayOrString
}
}
@@ -1,4 +1,4 @@
var { h, when, map, Proxy, Struct, Value, computed } = require('mutant')
var { h, when, map, Proxy, Struct, Value, computed, watch } = require('mutant')
var nest = require('depnest')
var ref = require('ssb-ref')
var AnchorHook = require('../../../../lib/anchor-hook')
@@ -32,6 +32,7 @@ exports.create = function (api) {
type: 'post',
root: Proxy(id),
branch: Proxy(id),
reply: Value(undefined),
channel: Value(undefined),
recps: Value(undefined)
})
@@ -66,6 +67,7 @@ exports.create = function (api) {
// what happens in private stays in private!
meta.recps.set(value.content.recps)
var author = value.author
var root = api.message.sync.root({key: id, value}) || id
var isReply = id !== root
var thread = api.feed.obs.thread(id, {branch: isReply})
@@ -101,6 +103,14 @@ exports.create = function (api) {
compose
])
result.set(when(thread.sync, container, loader))
watch(anchor, (anchor) => {
if (anchor === 'reply') {
meta.reply.set([author])
} else {
meta.reply.set(undefined)
}
})
})
var view = h('div', {className: 'SplitView'}, [

0 comments on commit 8b4e456

Please sign in to comment.