git ssb

16+

Dominic / patchbay



Tree: 8a51c32a71a79eaf5aacc86fda73831f1a6356dc

Files: 8a51c32a71a79eaf5aacc86fda73831f1a6356dc / app / page / private.js

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

Built with git-ssb-web