git ssb

16+

Dominic / patchbay



Tree: 29997160555aa9df4541f65ba3ca7b58d4a8c9c4

Files: 29997160555aa9df4541f65ba3ca7b58d4a8c9c4 / modules / private.js

1929 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
8var plugs = require('../plugs')
9
10var message_render = plugs.first(exports.message_render = [])
11var message_compose = plugs.first(exports.message_compose = [])
12var message_unbox = plugs.first(exports.message_unbox = [])
13var sbot_log = plugs.first(exports.sbot_log = [])
14var sbot_whoami = plugs.first(exports.sbot_whoami = [])
15
16function unbox () {
17 return pull(
18 pull.filter(function (msg) {
19 return 'string' == typeof msg.value.content
20 }),
21 pull.map(function (msg) {
22 return message_unbox(msg)
23 }),
24 pull.filter(Boolean)
25 )
26}
27
28exports.screen_view = function (path) {
29 if(path === '/private') {
30 var id = null
31 sbot_whoami(function (err, me) {
32 id = me.id
33 })
34
35 var compose = message_compose(
36 {type: 'post', recps: [], private: true},
37 function (msg) {
38 msg.recps = [id].concat(msg.mentions).filter(function (e) {
39 return ref.isFeed('string' === typeof e ? e : e.link)
40 })
41 if(!msg.recps.length)
42 throw new Error('cannot make private message without recipients - just mention them in the message')
43 return msg
44 })
45
46 var content = h('div.column.scroller__content')
47 var div = h('div.column.scroller',
48 {style: {'overflow':'auto'}},
49 h('div.scroller__wrapper', compose, content)
50 )
51
52 pull(
53 sbot_log({old: false}),
54 unbox(),
55 Scroller(div, content, message_render, true, false)
56 )
57
58 pull(
59 u.next(sbot_log, {reverse: true, limit: 1000}),
60 unbox(),
61 Scroller(div, content, message_render, false, false, function (err) {
62 if(err) throw err
63 })
64 )
65
66 return div
67 }
68}
69
70exports.message_meta = function (msg) {
71 if(msg.value.private)
72 return "PRIVATE"
73}
74
75
76
77
78
79
80
81
82
83
84

Built with git-ssb-web