git ssb

1+

punkmonk.termux / mvd



forked from ev / mvd

Commit 340be07ddda4e511bfce40504bcda7b43381ed1b

unbox private messages in the client

Ev Bogue committed on 6/25/2018, 6:49:17 PM
Parent: b39e6bdb22180e6de03344b285238d49ec5ed7c1

Files changed

index.jschanged
render.jschanged
views.jschanged
index.jsView
@@ -30,8 +30,9 @@
3030 }
3131 }
3232 })),
3333 h('li', h('a', {href: '#' }, 'All')),
34+ h('li', h('a', {href: '#private' }, 'Private')),
3435 h('li', h('a', {href: '#mentions' }, 'Mentions')),
3536 h('li', h('a', {href: '#key' }, 'Key')),
3637 h('li.right', h('a', {href: '#about'}, '?'))
3738 )
render.jsView
@@ -7,9 +7,8 @@
77 var tools = require('./tools')
88
99 var config = require('./config')()
1010 var id = require('./keys').id
11-
1211 var avatar = require('./avatar')
1312
1413 module.exports = function (msg) {
1514 var message = h('div.message#' + msg.key.substring(0, 44))
@@ -24,13 +23,8 @@
2423 message.appendChild(tools.mini(msg, muted))
2524 return message
2625 }
2726
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- }*/
3327 else if (msg.value.content.type == 'contact') {
3428 if (msg.value.content.following == true) {
3529 var following = h('span', ' follows ', h('a', {href: '#' + msg.value.content.contact}, avatar.name(msg.value.content.contact)))
3630 message.appendChild(tools.mini(msg, following))
views.jsView
@@ -15,9 +15,10 @@
1515 var tools = require('./tools')
1616 var avatar = require('./avatar')
1717 var id = require('./keys').id
1818
19-var fs = require('fs')
19+var ssbKeys = require('ssb-keys')
20+var keys = require('./keys')
2021
2122 var compose = require('./compose')
2223
2324 var about = function () {
@@ -29,8 +30,44 @@
2930
3031 screen.appendChild(hyperscroll(content))
3132 }
3233
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+
3370 var mentionsStream = function () {
3471 var content = h('div.content')
3572
3673 var screen = document.getElementById('screen')
@@ -274,10 +311,10 @@
274311 } else if (src == 'mentions') {
275312 mentionsStream()
276313 } else if (src == 'about') {
277314 about()
278- } else if (src == 'edit') {
279- edit()
315+ } else if (src == 'private') {
316+ privateStream()
280317 } else if (src == 'key') {
281318 keyPage()
282319 } else {
283320 everythingStream()

Built with git-ssb-web