Files: f231b14ed22c7cf47457f3dc2841ebd18965086c / app / html / page / channel.js
1360 bytesRaw
1 | const nest = require('depnest') |
2 | const pull = require('pull-stream') |
3 | const Scroller = require('pull-scroll') |
4 | |
5 | exports.gives = nest('app.html.page') |
6 | |
7 | exports.needs = nest({ |
8 | 'app.html': { |
9 | filter: 'first', |
10 | scroller: 'first' |
11 | }, |
12 | 'feed.pull.channel': 'first', |
13 | message: { |
14 | html: { |
15 | compose: 'first', |
16 | render: 'first' |
17 | } |
18 | // 'sync.unbox': 'first' |
19 | } |
20 | }) |
21 | |
22 | exports.create = function (api) { |
23 | return nest('app.html.page', channelView) |
24 | |
25 | function channelView (path) { |
26 | if (path && !path.match(/#[^\s]+/)) return |
27 | |
28 | const channel = path.substr(1) |
29 | const composer = api.message.html.compose({ meta: { type: 'post', channel } }) |
30 | const { filterMenu, filterDownThrough, filterUpThrough, resetFeed } = api.app.html.filter(draw) |
31 | const { container, content } = api.app.html.scroller({ prepend: [composer, filterMenu] }) |
32 | |
33 | function draw () { |
34 | resetFeed({ container, content }) |
35 | |
36 | const openChannelSource = api.feed.pull.channel(channel) |
37 | |
38 | pull( |
39 | openChannelSource({old: false}), |
40 | filterUpThrough(), |
41 | Scroller(container, content, api.message.html.render, true, false) |
42 | ) |
43 | |
44 | pull( |
45 | openChannelSource({reverse: true}), |
46 | filterDownThrough(), |
47 | Scroller(container, content, api.message.html.render, false, false) |
48 | ) |
49 | } |
50 | draw() |
51 | |
52 | return container |
53 | } |
54 | } |
55 | |
56 |
Built with git-ssb-web