git ssb

16+

Dominic / patchbay



Tree: 8ae0df05df1185783cf0ee77113ce4bcc4531bdd

Files: 8ae0df05df1185783cf0ee77113ce4bcc4531bdd / router / html / page / private.js

1403 bytesRaw
1const nest = require('depnest')
2const pull = require('pull-stream')
3const Scroller = require('pull-scroll')
4const next = require('../../../junk/next-stepper')
5const ref = require('ssb-ref')
6
7exports.gives = nest('router.html.page')
8
9exports.needs = nest({
10 'feed.pull.private': 'first',
11 'keys.sync.id': 'first',
12 'main.html.scroller': 'first',
13 'message.html': {
14 compose: 'first',
15 render: 'first'
16 }
17})
18
19exports.create = function (api) {
20 return nest('router.html.page', privatePage)
21
22 function privatePage (path) {
23 if (path !== '/private') return
24
25 const id = api.keys.sync.id()
26
27 const composer = api.message.html.compose({
28 meta: { type: 'post' },
29 prepublish: meta => {
30 meta.recps = [id, ...meta.mentions]
31 .filter(m => ref.isFeed(typeof m === 'string' ? m : m.link))
32 return meta
33 },
34 placeholder: 'Write a private message. \n\n@mention users in the first message to start a private thread.'}
35 )
36 const { container, content } = api.main.html.scroller({ prepend: composer })
37
38 pull(
39 next(api.feed.pull.private, {old: false, limit: 100}),
40 Scroller(container, content, api.message.html.render, true, false)
41 )
42
43 pull(
44 next(api.feed.pull.private, {reverse: true, limit: 100, live: false}),
45 Scroller(container, content, api.message.html.render, false, false)
46 )
47
48 return container
49 }
50}
51
52

Built with git-ssb-web