git ssb

16+

Dominic / patchbay



Tree: 9510d7867738dfa7a4aaee17c183c86bb081f55e

Files: 9510d7867738dfa7a4aaee17c183c86bb081f55e / app / page / channel.js

1444 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': {
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.page.channel', channelView)
24
25 function channelView (location) {
26 const { channel } = location
27 const channelName = channel.substr(1)
28 const composer = api.message.html.compose({ meta: { type: 'post', channelName } })
29 const { filterMenu, filterDownThrough, filterUpThrough, resetFeed } = api.app.html.filter(draw)
30 const { container, content } = api.app.html.scroller({ prepend: [composer, filterMenu] })
31
32 function draw () {
33 resetFeed({ container, content })
34
35 const openChannelSource = api.feed.pull.channel(channelName)
36
37 pull(
38 openChannelSource({old: false}),
39 filterUpThrough(),
40 Scroller(container, content, api.message.html.render, true, false)
41 )
42
43 pull(
44 openChannelSource({reverse: true}),
45 filterDownThrough(),
46 Scroller(container, content, api.message.html.render, false, false)
47 )
48 }
49 draw()
50
51 container.id = JSON.stringify(location)
52 container.title = channel
53 return container
54 }
55}
56
57

Built with git-ssb-web