git ssb

16+

Dominic / patchbay



Tree: a41e049ca3755ddfd97e7f53c9da830711e636f1

Files: a41e049ca3755ddfd97e7f53c9da830711e636f1 / app / page / public.js

1904 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 location,
38 meta: { type: 'post' },
39 placeholder: 'Write a public message'
40 })
41 const { filterMenu, filterDownThrough, filterUpThrough, resetFeed } = api.app.html.filter(draw)
42 const { container, content } = api.app.html.scroller({ prepend: [composer, filterMenu] })
43
44 // TODO : build a pull-stream which has seperate state + rendering
45 function draw () {
46 resetFeed({ container, content })
47
48 const render = (msg) => {
49 // if (msg.value.content.type === 'about') debugger
50 return api.message.html.render(msg)
51 }
52
53 pull(
54 next(api.feed.pull.public, {old: false, limit: 100}, ['value', 'timestamp']),
55 filterDownThrough(),
56 Scroller(container, content, render, true, false)
57 )
58
59 pull(
60 next(api.feed.pull.public, {reverse: true, limit: 100, live: false}, ['value', 'timestamp']),
61 filterUpThrough(),
62 Scroller(container, content, render, false, false)
63 )
64 }
65 draw()
66
67 container.title = '/public'
68 return container
69 }
70}
71

Built with git-ssb-web