git ssb

16+

Dominic / patchbay



Tree: 581254ceab1c7f5bcd943eb7f7393dfba611529c

Files: 581254ceab1c7f5bcd943eb7f7393dfba611529c / app / page / public.js

2001 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 console.log('LOADING PUBLIC PAGE')
24 return nest({
25 'app.html.menuItem': menuItem,
26 'app.page.public': publicPage
27 })
28
29 function menuItem () {
30 return h('a', {
31 style: { order: 1 },
32 'ev-click': () => api.app.sync.goTo({ page: 'public' })
33 }, '/public')
34 }
35
36 function publicPage (location) {
37 const composer = api.message.html.compose({
38 location,
39 meta: { type: 'post' },
40 placeholder: 'Write a public message'
41 })
42 const { filterMenu, filterDownThrough, filterUpThrough, resetFeed } = api.app.html.filter(draw)
43 const { container, content } = api.app.html.scroller({ prepend: [composer, filterMenu] })
44
45 // TODO : build a pull-stream which has seperate state + rendering
46 function draw () {
47 resetFeed({ container, content })
48
49 const render = (msg) => {
50 // if (msg.value.content.type === 'about') debugger
51 return api.message.html.render(msg)
52 }
53
54 // TODO - change to use ssb-query, streamed by publish time
55 pull(
56 next(api.feed.pull.public, {old: false, limit: 100, live: true}, ['timestamp']),
57 filterUpThrough(),
58 Scroller(container, content, render, true, false)
59 )
60
61 pull(
62 next(api.feed.pull.public, {reverse: true, limit: 100, live: false}, ['timestamp']),
63 filterDownThrough(),
64 Scroller(container, content, render, false, false)
65 )
66 }
67 draw()
68
69 container.title = '/public'
70 return container
71 }
72}
73

Built with git-ssb-web