git ssb

16+

Dominic / patchbay



Tree: c05e98ca66758d61b5968645419a1efaaad16bfd

Files: c05e98ca66758d61b5968645419a1efaaad16bfd / app / page / channel.js

1365 bytesRaw
1const nest = require('depnest')
2const pull = require('pull-stream')
3const Scroller = require('pull-scroll')
4
5exports.gives = nest('app.page.channel')
6
7exports.needs = nest({
8 'app.html.filter': 'first',
9 'app.html.scroller': 'first',
10 'feed.pull.channel': 'first',
11 'message.html.compose': 'first',
12 'message.html.render': 'first'
13})
14
15exports.create = function (api) {
16 return nest('app.page.channel', channelView)
17
18 function channelView (location) {
19 const { channel } = location
20
21 const channelName = channel.substr(1)
22 const composer = api.message.html.compose({ meta: { type: 'post', channel: channelName } })
23 const { filterMenu, filterDownThrough, filterUpThrough, resetFeed } = api.app.html.filter(draw)
24 const { container, content } = api.app.html.scroller({ prepend: [composer, filterMenu] })
25
26 function draw () {
27 resetFeed({ container, content })
28
29 const openChannelSource = api.feed.pull.channel(channelName)
30
31 pull(
32 openChannelSource({old: false}),
33 filterUpThrough(),
34 Scroller(container, content, api.message.html.render, true, false)
35 )
36
37 pull(
38 openChannelSource({reverse: true}),
39 filterDownThrough(),
40 Scroller(container, content, api.message.html.render, false, false)
41 )
42 }
43 draw()
44
45 container.title = channel
46 return container
47 }
48}
49

Built with git-ssb-web