Commit 70fb8c8a016f2f59cb6933d6505c3d65dd426581
add channel view
mix irving committed on 3/20/2017, 3:02:41 AMParent: 879b5816387bec7a20dde4e29e4a3955f212af41
Files changed
router/html/page/thread.js | changed |
router/html/page/channel.js | added |
router/html/page/thread.js | ||
---|---|---|
@@ -5,8 +5,9 @@ | ||
5 | 5 | const ref = require('ssb-ref') |
6 | 6 | |
7 | 7 | exports.gives = nest('router.html.page') |
8 | 8 | |
9 | +// TODO - seperate out public and private thread rendering | |
9 | 10 | exports.needs = nest({ |
10 | 11 | // 'feed.pull.public': 'first', |
11 | 12 | 'keys.sync.id': 'first', |
12 | 13 | 'main.html.scroller': 'first', |
router/html/page/channel.js | ||
---|---|---|
@@ -1,0 +1,45 @@ | ||
1 | +const nest = require('depnest') | |
2 | +const pull = require('pull-stream') | |
3 | +const Scroller = require('pull-scroll') | |
4 | + | |
5 | +exports.gives = nest('router.html.page') | |
6 | + | |
7 | +exports.needs = nest({ | |
8 | + 'feed.pull.channel': 'first', | |
9 | + 'main.html.scroller': 'first', | |
10 | + message: { | |
11 | + html: { | |
12 | + compose: 'first', | |
13 | + render: 'first' | |
14 | + } | |
15 | + // 'sync.unbox': 'first' | |
16 | + } | |
17 | +}) | |
18 | + | |
19 | +exports.create = function (api) { | |
20 | + return nest('router.html.page', channelView) | |
21 | + | |
22 | + function channelView (path) { | |
23 | + if (path[0] !== '#') return | |
24 | + | |
25 | + var channel = path.substr(1) | |
26 | + | |
27 | + var composer = api.message.html.compose({ meta: { type: 'post', channel } }) | |
28 | + var { container, content } = api.main.html.scroller({ prepend: composer }) | |
29 | + | |
30 | + var openChannelSource = api.feed.pull.channel(channel) | |
31 | + | |
32 | + pull( | |
33 | + openChannelSource({old: false}), | |
34 | + Scroller(container, content, api.message.html.render, true, false) | |
35 | + ) | |
36 | + | |
37 | + pull( | |
38 | + openChannelSource({reverse: true}), | |
39 | + Scroller(container, content, api.message.html.render, false, false) | |
40 | + ) | |
41 | + | |
42 | + return container | |
43 | + } | |
44 | +} | |
45 | + |
Built with git-ssb-web