git ssb

16+

Dominic / patchbay



Tree: 822fd812786ca6ef22677d876b8c056c0ad8cc82

Files: 822fd812786ca6ef22677d876b8c056c0ad8cc82 / router / html / page / public.js

1363 bytesRaw
1const nest = require('depnest')
2const { h } = require('mutant')
3const pull = require('pull-stream')
4const Scroller = require('pull-scroll')
5const next = require('../../../junk/next-stepper')
6
7exports.gives = nest({
8 'router.html': {
9 page: true,
10 simpleRoute: true
11 }
12})
13
14exports.needs = nest({
15 'feed.pull.public': 'first',
16 'message.html': {
17 compose: 'first',
18 render: 'first'
19 },
20 'main.html.scroller': 'first'
21})
22
23exports.create = function (api) {
24 const route = '/public'
25
26 return nest({
27 'router.html': {
28 page: publicPage,
29 simpleRoute: menuItem
30 }
31 })
32
33 function menuItem (handleClick) {
34 return h('a', {
35 style: { order: 1 },
36 'ev-click': () => handleClick(route)
37 }, route)
38 }
39
40 function publicPage (path) {
41 if (path !== route) return
42
43 const composer = api.message.html.compose({
44 meta: { type: 'post' },
45 placeholder: 'Write a public message'
46 })
47 const { container, content } = api.main.html.scroller({ prepend: composer })
48
49 pull(
50 next(api.feed.pull.public, {old: false, limit: 100}),
51 Scroller(container, content, api.message.html.render, true, false)
52 )
53
54 pull(
55 next(api.feed.pull.public, {reverse: true, limit: 100, live: false}),
56 Scroller(container, content, api.message.html.render, false, false)
57 )
58
59 return container
60 }
61}
62
63

Built with git-ssb-web