git ssb

16+

Dominic / patchbay



Tree: b755e93b29216ff4f3cc1b14472292cca8524023

Files: b755e93b29216ff4f3cc1b14472292cca8524023 / app / page / public.js

1964 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 // TODO - change to use ssb-query, streamed by publish time
54 pull(
55 next(api.feed.pull.public, {old: false, limit: 100, live: true}, ['timestamp']),
56 filterUpThrough(),
57 Scroller(container, content, render, true, false)
58 )
59
60 pull(
61 next(api.feed.pull.public, {reverse: true, limit: 100, live: false}, ['timestamp']),
62 filterDownThrough(),
63 Scroller(container, content, render, false, false)
64 )
65 }
66 draw()
67
68 container.title = '/public'
69 return container
70 }
71}
72

Built with git-ssb-web