git ssb

16+

Dominic / patchbay



Tree: 1ffe6d6dd1a7a18ae9de5a224286e102f420febe

Files: 1ffe6d6dd1a7a18ae9de5a224286e102f420febe / modules / private.js

2056 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
30 if(path === '/private') {
31 if(process.title === 'browser')
32 return h('div', h('h1', 'private messages not currently supported'))
33
34
35 var id = null
36 sbot_whoami(function (err, me) {
37 id = me.id
38 })
39
40 var compose = message_compose(
41 {type: 'post', recps: [], private: true},
42 function (msg) {
43 msg.recps = [id].concat(msg.mentions).filter(function (e) {
44 return ref.isFeed('string' === typeof e ? e : e.link)
45 })
46 if(!msg.recps.length)
47 throw new Error('cannot make private message without recipients - just mention them in the message')
48 return msg
49 })
50
51 var content = h('div.column.scroller__content')
52 var div = h('div.column.scroller',
53 {style: {'overflow':'auto'}},
54 h('div.scroller__wrapper', compose, content)
55 )
56
57 pull(
58 sbot_log({old: false}),
59 unbox(),
60 Scroller(div, content, message_render, true, false)
61 )
62
63 pull(
64 u.next(sbot_log, {reverse: true, limit: 1000}),
65 unbox(),
66 Scroller(div, content, message_render, false, false, function (err) {
67 if(err) throw err
68 })
69 )
70
71 return div
72 }
73}
74
75exports.message_meta = function (msg) {
76 if(msg.value.private)
77 return h('span', 'PRIVATE')
78}
79
80
81
82
83
84
85
86
87
88
89
90
91

Built with git-ssb-web