Files: 3c63691a3ff381ff83e86a97ce3246807bccae1e / router / html / page / private.js
1403 bytesRaw
1 | const nest = require('depnest') |
2 | const pull = require('pull-stream') |
3 | const Scroller = require('pull-scroll') |
4 | const next = require('../../../junk/next-stepper') |
5 | const ref = require('ssb-ref') |
6 | |
7 | exports.gives = nest('router.html.page') |
8 | |
9 | exports.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 | |
19 | exports.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