git ssb

16+

Dominic / patchbay



Tree: 91116b86a5d782a02e668da8c5990803728c90d4

Files: 91116b86a5d782a02e668da8c5990803728c90d4 / app / html / page / channel.js

1360 bytesRaw
1const nest = require('depnest')
2const pull = require('pull-stream')
3const Scroller = require('pull-scroll')
4
5exports.gives = nest('app.html.page')
6
7exports.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
22exports.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