git ssb

16+

Dominic / patchbay



Tree: 437facf41d277081453b193b5e9cc808704399ef

Files: 437facf41d277081453b193b5e9cc808704399ef / modules / private.js

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

Built with git-ssb-web