git ssb

16+

Dominic / patchbay



Tree: 7c78ad02a9f1b3e1bc334486559ed3013e802ec4

Files: 7c78ad02a9f1b3e1bc334486559ed3013e802ec4 / app / html / page / public.js

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

Built with git-ssb-web