Commit ead85ed3a63a22c9fc634e596226037135a8f814
Merge pull request #312 from ssbc/support-unbox-links
Support links with unbox keyChristian Bundy authored on 4/2/2019, 5:57:01 PM
GitHub committed on 4/2/2019, 5:57:01 PM
Parent: 09faa08d041f29280c535b5995600d3170b76fc2
Parent: 6c59c792588683040c22962f3e654c84ed584313
Files changed
app/page/thread.js | changed |
message/html/render/about.js | changed |
router/async/normalise.js | changed |
app/page/thread.js | |||
---|---|---|---|
@@ -22,9 +22,11 @@ | |||
22 | 22 … | exports.create = function (api) { | |
23 | 23 … | return nest('app.page.thread', threadPage) | |
24 | 24 … | ||
25 | 25 … | function threadPage (location) { | |
26 | - const root = get(location, 'value.content.root') || get(location, 'value.content.about') || location.key | ||
26 … | + let root = get(location, 'value.content.root') || get(location, 'value.content.about') || location.key | ||
27 … | + if (location.value && location.value.unbox) // direct link with unbox key | ||
28 … | + root = location.key | ||
27 | 29 … | const msg = location.key | |
28 | 30 … | if (msg !== root) scrollDownToMessage(msg) | |
29 | 31 … | ||
30 | 32 … | const { messages, isPrivate, rootId, lastId, channel, recps } = api.feed.obs.thread(root) | |
@@ -40,16 +42,20 @@ | |||
40 | 42 … | feedIdsInThread: computed(messages, msgs => msgs.map(m => m.value.author)), | |
41 | 43 … | placeholder: 'Write a reply', | |
42 | 44 … | shrink: false | |
43 | 45 … | }) | |
46 … | + | ||
44 | 47 … | onceTrue(channel, ch => { | |
45 | 48 … | const channelInput = composer.querySelector('input') | |
46 | 49 … | channelInput.value = `#${ch}` | |
47 | 50 … | channelInput.disabled = true | |
48 | 51 … | }) | |
49 | 52 … | ||
50 | 53 … | const content = map(messages, m => { | |
51 | - const message = api.message.html.render(resolve(m), { pageId: root }) | ||
54 … | + let msg = resolve(m) | ||
55 … | + if (msg.key == location.key && location.value && location.value.unbox) // we have an unbox key, so message is already unboxed | ||
56 … | + msg = location | ||
57 … | + const message = api.message.html.render(msg, { pageId: root }) | ||
52 | 58 … | markReadWhenVisible(message) | |
53 | 59 … | return message | |
54 | 60 … | }, { comparer }) | |
55 | 61 … |
message/html/render/about.js | ||
---|---|---|
@@ -1,7 +1,7 @@ | ||
1 | 1 … | const nest = require('depnest') |
2 | 2 … | const extend = require('xtend') |
3 | -const { isFeed, isMsg, isBlob } = require('ssb-ref') | |
3 … | +const { isFeed, isBlob } = require('ssb-ref') | |
4 | 4 … | const { h } = require('mutant') |
5 | 5 … | |
6 | 6 … | exports.gives = nest('message.html.render') |
7 | 7 … |
router/async/normalise.js | ||
---|---|---|
@@ -1,6 +1,6 @@ | ||
1 | 1 … | const nest = require('depnest') |
2 | -const { isBlobLink, isFeed, isMsg } = require('ssb-ref') | |
2 … | +const { isBlobLink, isFeed, isMsg, parseLink } = require('ssb-ref') | |
3 | 3 … | const ssbUri = require('ssb-uri') |
4 | 4 … | |
5 | 5 … | exports.gives = nest('router.async.normalise') |
6 | 6 … | |
@@ -30,14 +30,21 @@ | ||
30 | 30 … | cb(err) |
31 | 31 … | } |
32 | 32 … | } |
33 | 33 … | |
34 | - if (isMsg(location)) { | |
35 | - api.sbot.async.get(location, (err, value) => { | |
34 … | + var link = parseLink(location) | |
35 … | + | |
36 … | + if (link && isMsg(link.link)) { | |
37 … | + var params = { id: link.link } | |
38 … | + if (link.query && link.query.unbox) { | |
39 … | + params.private = true | |
40 … | + params.unbox = link.query.unbox | |
41 … | + } | |
42 … | + api.sbot.async.get(params, function (err, value) { | |
36 | 43 … | if (err) cb(err) |
37 | 44 … | else { |
38 | 45 … | if (typeof value.content === 'string') value = api.message.sync.unbox(value) |
39 | - cb(null, { key: location, value }) | |
46 … | + cb(null, { key: link.link, value }) | |
40 | 47 … | } |
41 | 48 … | }) |
42 | 49 … | } else if (isBlobLink(location)) { |
43 | 50 … | // handles public & private blobs |
Built with git-ssb-web