Files: a70580f24e1b7b106a074503369cc1b096b6080d / app / html / page / public.js
1349 bytesRaw
1 | const nest = require('depnest') |
2 | const { h } = require('mutant') |
3 | const pull = require('pull-stream') |
4 | const Scroller = require('pull-scroll') |
5 | const next = require('../../../junk/next-stepper') |
6 | |
7 | exports.gives = nest({ |
8 | 'app.html': { |
9 | page: true, |
10 | menuItem: true |
11 | } |
12 | }) |
13 | |
14 | exports.needs = nest({ |
15 | 'feed.pull.public': 'first', |
16 | 'message.html': { |
17 | compose: 'first', |
18 | render: 'first' |
19 | }, |
20 | 'app.html.scroller': 'first' |
21 | }) |
22 | |
23 | exports.create = function (api) { |
24 | const route = '/public' |
25 | |
26 | return nest({ |
27 | 'app.html': { |
28 | page: publicPage, |
29 | menuItem: 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.app.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