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