Files: 7c22ec2ce201b04fa7c787e4f7833eb28065327b / modules_basic / public.js
1159 bytesRaw
1 | const fs = require('fs') |
2 | const h = require('hyperscript') |
3 | const u = require('../util') |
4 | const pull = require('pull-stream') |
5 | const Scroller = require('pull-scroll') |
6 | |
7 | exports.needs = { |
8 | build_scroller: 'first', |
9 | message_render: 'first', |
10 | message_compose: 'first', |
11 | sbot_log: 'first', |
12 | } |
13 | |
14 | exports.gives = { |
15 | builtin_tabs: true, |
16 | screen_view: true, |
17 | // mcss: true |
18 | } |
19 | |
20 | exports.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