git ssb

16+

Dominic / patchbay



Tree: 07cfe9bf013a2baa61f2d075994dc78be9aa9309

Files: 07cfe9bf013a2baa61f2d075994dc78be9aa9309 / app / page / public.js

1888 bytesRaw
1const nest = require('depnest')
2const { h } = require('mutant')
3const pull = require('pull-stream')
4const Scroller = require('pull-scroll')
5
6const next = require('../../junk/next-stepper')
7
8exports.gives = nest({
9 'app.html.menuItem': true,
10 'app.page.public': true
11})
12
13exports.needs = nest({
14 'app.html.filter': 'first',
15 'app.html.scroller': 'first',
16 'app.sync.goTo': 'first',
17 'feed.pull.public': 'first',
18 'message.html.compose': 'first',
19 'message.html.render': 'first'
20})
21
22exports.create = function (api) {
23 return nest({
24 'app.html.menuItem': menuItem,
25 'app.page.public': publicPage
26 })
27
28 function menuItem () {
29 return h('a', {
30 style: { order: 1 },
31 'ev-click': () => api.app.sync.goTo({ page: 'public' })
32 }, '/public')
33 }
34
35 function publicPage (location) {
36 const composer = api.message.html.compose({
37 meta: { type: 'post' },
38 placeholder: 'Write a public message'
39 })
40 const { filterMenu, filterDownThrough, filterUpThrough, resetFeed } = api.app.html.filter(draw)
41 const { container, content } = api.app.html.scroller({ prepend: [composer, filterMenu] })
42
43 // TODO : build a pull-stream which has seperate state + rendering
44 function draw () {
45 resetFeed({ container, content })
46
47 const render = (msg) => {
48 // if (msg.value.content.type === 'about') debugger
49 return api.message.html.render(msg)
50 }
51
52 pull(
53 next(api.feed.pull.public, {old: false, limit: 100}, ['value', 'timestamp']),
54 filterDownThrough(),
55 Scroller(container, content, render, true, false)
56 )
57
58 pull(
59 next(api.feed.pull.public, {reverse: true, limit: 100, live: false}, ['value', 'timestamp']),
60 filterUpThrough(),
61 Scroller(container, content, render, false, false)
62 )
63 }
64 draw()
65
66 container.title = '/public'
67 return container
68 }
69}
70

Built with git-ssb-web