Commit 340be07ddda4e511bfce40504bcda7b43381ed1b
unbox private messages in the client
Ev Bogue committed on 6/25/2018, 6:49:17 PMParent: b39e6bdb22180e6de03344b285238d49ec5ed7c1
Files changed
index.js | changed |
render.js | changed |
views.js | changed |
index.js | ||
---|---|---|
@@ -30,8 +30,9 @@ | ||
30 | 30 | } |
31 | 31 | } |
32 | 32 | })), |
33 | 33 | h('li', h('a', {href: '#' }, 'All')), |
34 | + h('li', h('a', {href: '#private' }, 'Private')), | |
34 | 35 | h('li', h('a', {href: '#mentions' }, 'Mentions')), |
35 | 36 | h('li', h('a', {href: '#key' }, 'Key')), |
36 | 37 | h('li.right', h('a', {href: '#about'}, '?')) |
37 | 38 | ) |
render.js | ||
---|---|---|
@@ -7,9 +7,8 @@ | ||
7 | 7 | var tools = require('./tools') |
8 | 8 | |
9 | 9 | var config = require('./config')() |
10 | 10 | var id = require('./keys').id |
11 | - | |
12 | 11 | var avatar = require('./avatar') |
13 | 12 | |
14 | 13 | module.exports = function (msg) { |
15 | 14 | var message = h('div.message#' + msg.key.substring(0, 44)) |
@@ -24,13 +23,8 @@ | ||
24 | 23 | message.appendChild(tools.mini(msg, muted)) |
25 | 24 | return message |
26 | 25 | } |
27 | 26 | |
28 | - /*if (msg.value.private == true) { | |
29 | - var privateMsg = h('span', ' ', h('img.emoji', {src: config.emojiUrl + 'lock.png'}), ' ', h('button.btn', 'Open')) | |
30 | - message.appendChild(tools.mini(msg, privateMsg)) | |
31 | - return message | |
32 | - }*/ | |
33 | 27 | else if (msg.value.content.type == 'contact') { |
34 | 28 | if (msg.value.content.following == true) { |
35 | 29 | var following = h('span', ' follows ', h('a', {href: '#' + msg.value.content.contact}, avatar.name(msg.value.content.contact))) |
36 | 30 | message.appendChild(tools.mini(msg, following)) |
views.js | ||
---|---|---|
@@ -15,9 +15,10 @@ | ||
15 | 15 | var tools = require('./tools') |
16 | 16 | var avatar = require('./avatar') |
17 | 17 | var id = require('./keys').id |
18 | 18 | |
19 | -var fs = require('fs') | |
19 | +var ssbKeys = require('ssb-keys') | |
20 | +var keys = require('./keys') | |
20 | 21 | |
21 | 22 | var compose = require('./compose') |
22 | 23 | |
23 | 24 | var about = function () { |
@@ -29,8 +30,44 @@ | ||
29 | 30 | |
30 | 31 | screen.appendChild(hyperscroll(content)) |
31 | 32 | } |
32 | 33 | |
34 | +var privateStream = function () { | |
35 | + var content = h('div.content') | |
36 | + var screen = document.getElementById('screen') | |
37 | + screen.appendChild(hyperscroll(content)) | |
38 | + | |
39 | + function createStream (opts) { | |
40 | + return pull( | |
41 | + More(sbot.createLogStream, opts), | |
42 | + pull.filter(function (msg) { | |
43 | + return 'string' == typeof msg.value.content | |
44 | + }), | |
45 | + pull.filter(function (msg) { | |
46 | + var unboxed = ssbKeys.unbox(msg.value.content, keys) | |
47 | + if (unboxed) { | |
48 | + msg.value.content = unboxed | |
49 | + msg.value.private = true | |
50 | + return msg | |
51 | + } | |
52 | + }), | |
53 | + pull.map(function (msg) { | |
54 | + return render(msg) | |
55 | + }) | |
56 | + ) | |
57 | + } | |
58 | + | |
59 | + pull( | |
60 | + createStream({old: false, limit: 1000}), | |
61 | + stream.top(content) | |
62 | + ) | |
63 | + | |
64 | + pull( | |
65 | + createStream({reverse: true, live: false, limit: 1000}), | |
66 | + stream.bottom(content) | |
67 | + ) | |
68 | +} | |
69 | + | |
33 | 70 | var mentionsStream = function () { |
34 | 71 | var content = h('div.content') |
35 | 72 | |
36 | 73 | var screen = document.getElementById('screen') |
@@ -274,10 +311,10 @@ | ||
274 | 311 | } else if (src == 'mentions') { |
275 | 312 | mentionsStream() |
276 | 313 | } else if (src == 'about') { |
277 | 314 | about() |
278 | - } else if (src == 'edit') { | |
279 | - edit() | |
315 | + } else if (src == 'private') { | |
316 | + privateStream() | |
280 | 317 | } else if (src == 'key') { |
281 | 318 | keyPage() |
282 | 319 | } else { |
283 | 320 | everythingStream() |
Built with git-ssb-web