git ssb

16+

Dominic / patchbay



Tree: 9510d7867738dfa7a4aaee17c183c86bb081f55e

Files: 9510d7867738dfa7a4aaee17c183c86bb081f55e / app / page / private.js

2110 bytesRaw
1const nest = require('depnest')
2const { h } = require('mutant')
3const pull = require('pull-stream')
4const Scroller = require('pull-scroll')
5const ref = require('ssb-ref')
6
7const next = require('../../junk/next-stepper')
8
9exports.gives = nest({
10 'app.html.menuItem': true,
11 'app.page.private': true,
12})
13
14exports.needs = nest({
15 'app.html': {
16 filter: 'first',
17 scroller: 'first'
18 },
19 'app.sync.goTo': 'first',
20 'feed.pull.private': 'first',
21 'keys.sync.id': 'first',
22 'message.html': {
23 compose: 'first',
24 render: 'first'
25 }
26})
27
28exports.create = function (api) {
29 const page = '/private'
30
31 return nest({
32 'app.html.menuItem': menuItem,
33 'app.page.private': privatePage
34 })
35
36 function menuItem () {
37 return h('a', {
38 style: { order: 2 },
39 'ev-click': () => api.app.sync.goTo({ page })
40 }, page)
41 }
42
43 function privatePage (location) {
44 const id = api.keys.sync.id()
45
46 const composer = api.message.html.compose({
47 meta: { type: 'post' },
48 prepublish: meta => {
49 meta.recps = [id, ...(meta.mentions || [])]
50 .filter(m => ref.isFeed(typeof m === 'string' ? m : m.link))
51 return meta
52 },
53 placeholder: 'Write a private message. \n\n@mention users in the first message to start a private thread.'}
54 )
55 const { filterMenu, filterDownThrough, filterUpThrough, resetFeed } = api.app.html.filter(draw)
56 const { container, content } = api.app.html.scroller({ prepend: [ composer, filterMenu ] })
57
58 function draw () {
59 resetFeed({ container, content })
60
61 pull(
62 next(api.feed.pull.private, {old: false, limit: 100}, ['value', 'timestamp']),
63 filterDownThrough(),
64 Scroller(container, content, api.message.html.render, true, false)
65 )
66
67 pull(
68 next(api.feed.pull.private, {reverse: true, limit: 100, live: false}, ['value', 'timestamp']),
69 filterUpThrough(),
70 Scroller(container, content, api.message.html.render, false, false)
71 )
72 }
73 draw()
74
75 container.title = page
76 container.id = JSON.stringify(location)
77 return container
78 }
79}
80
81

Built with git-ssb-web