git ssb

16+

Dominic / patchbay



Tree: 60e60ca4a797710df7dce064463d8f89346ea260

Files: 60e60ca4a797710df7dce064463d8f89346ea260 / modules_basic / public.js

1159 bytesRaw
1const fs = require('fs')
2const h = require('hyperscript')
3const u = require('../util')
4const pull = require('pull-stream')
5const Scroller = require('pull-scroll')
6
7exports.needs = {
8 build_scroller: 'first',
9 message_render: 'first',
10 message_compose: 'first',
11 sbot_log: 'first',
12}
13
14exports.gives = {
15 builtin_tabs: true,
16 screen_view: true,
17 // mcss: true
18}
19
20exports.create = function (api) {
21 return {
22 builtin_tabs,
23 screen_view,
24 // mcss: () => fs.readFileSync(__filename.replace(/js$/, 'mcss'), 'utf8')
25 }
26
27 function builtin_tabs () {
28 return ['/public']
29 }
30
31 function screen_view (path, sbot) {
32 if(path !== '/public') return
33
34 const composer = api.message_compose({type: 'post'}, {placeholder: 'Write a public message'})
35 var { container, content } = api.build_scroller({ prepend: composer })
36
37 pull(
38 u.next(api.sbot_log, {old: false, limit: 100}),
39 Scroller(container, content, api.message_render, true, false)
40 )
41
42 pull(
43 u.next(api.sbot_log, {reverse: true, limit: 100, live: false}),
44 Scroller(container, content, api.message_render, false, false)
45 )
46
47 return container
48 }
49}
50
51

Built with git-ssb-web