git ssb

16+

Dominic / patchbay



Tree: 08e1fc42a3722f8f133fdcb3a7460462d599f889

Files: 08e1fc42a3722f8f133fdcb3a7460462d599f889 / modules / private.js

1650 bytesRaw
1var h = require('hyperscript')
2var ui = require('../ui')
3var u = require('../util')
4var pull = require('pull-stream')
5var Scroller = require('pull-scroll')
6var ref = require('ssb-ref')
7
8exports.message_render = []
9exports.message_compose = []
10exports.message_unbox = []
11
12function unbox () {
13 return pull(
14 pull.filter(function (msg) {
15 return 'string' == typeof msg.value.content
16 }),
17 pull.map(function (msg) {
18 return u.firstPlug(exports.message_unbox, msg)
19 }),
20 pull.filter(Boolean)
21 )
22}
23
24exports.screen_view = function (path, sbot) {
25 if(path === '/private') {
26 SBOT = sbot
27 var content = h('div.column')
28 var id = null
29 sbot.whoami(function (err, me) {
30 id = me.id
31 })
32
33 var div = h('div.column', {style: {'overflow':'auto'}},
34 u.firstPlug(exports.message_compose, {type: 'post', recps: [], private: true},
35 function (msg) {
36 msg.recps = [id].concat(msg.mentions).filter(function (e) {
37 return ref.isFeed('string' === typeof e ? e : e.link)
38 })
39 if(!msg.recps.length)
40 throw new Error('cannot make private message without recipients - just mention them in the message')
41 return msg
42 },
43 sbot),
44 content)
45 var render = ui.createRenderers(exports.message_render, sbot)
46
47 pull(
48 sbot.createLogStream({old: false}),
49 unbox(),
50 Scroller(div, content, render, true, false)
51 )
52
53 pull(
54 u.next(sbot.createLogStream, {reverse: true, limit: 1000}),
55 unbox(),
56 Scroller(div, content, render, false, false, function (err) {
57 if(err) throw err
58 })
59 )
60
61 return div
62 }
63}
64
65
66
67
68

Built with git-ssb-web