git ssb

16+

Dominic / patchbay



Tree: 9510d7867738dfa7a4aaee17c183c86bb081f55e

Files: 9510d7867738dfa7a4aaee17c183c86bb081f55e / app / page / public.js

2078 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': {
15 filter: 'first',
16 scroller: 'first'
17 },
18 'app.sync.goTo': 'first',
19 'feed.pull.public': 'first',
20 'message.html': {
21 compose: 'first',
22 render: 'first'
23 }
24})
25
26exports.create = function (api) {
27 const page = '/public'
28
29 return nest({
30 'app.html.menuItem': menuItem,
31 'app.page.public': publicPage,
32 })
33
34 function menuItem () {
35 return h('a', {
36 style: { order: 1 },
37 'ev-click': () => api.app.sync.goTo({ page })
38 }, page)
39 }
40
41 function publicPage (location) {
42 const composer = api.message.html.compose({
43 meta: { type: 'post' },
44 placeholder: 'Write a public message'
45 })
46 const { filterMenu, filterDownThrough, filterUpThrough, resetFeed } = api.app.html.filter(draw)
47 const { container, content } = api.app.html.scroller({ prepend: [composer, filterMenu] })
48
49 // TODO : build a pull-stream which has seperate state + rendering
50 function draw () {
51 resetFeed({ container, content })
52
53 const ren = (msg) => {
54 if (msg.value.content.type === 'about') debugger
55 api.message.html.render(msg)
56 }
57
58 pull(
59 next(api.feed.pull.public, {old: false, limit: 100}, ['value', 'timestamp']),
60 filterDownThrough(),
61 Scroller(container, content, api.message.html.render, true, false)
62 // Scroller(container, content, ren, true, false)
63 )
64
65 pull(
66 next(api.feed.pull.public, {reverse: true, limit: 100, live: false}, ['value', 'timestamp']),
67 filterUpThrough(),
68 Scroller(container, content, api.message.html.render, false, false)
69 // Scroller(container, content, ren, true, false)
70 )
71 }
72 draw()
73
74 container.id = JSON.stringify(location)
75 container.title = page
76 return container
77 }
78}
79
80

Built with git-ssb-web