git ssb

2+

mixmix / ticktack



Tree: cc9b1a7a5f4f79d8e0f7c4a2491a50f440ac9153

Files: cc9b1a7a5f4f79d8e0f7c4a2491a50f440ac9153 / app / page / channelShow.js

2103 bytesRaw
1const nest = require('depnest')
2const { h } = require('mutant')
3const pull = require('pull-stream')
4
5exports.gives = nest('app.page.channelShow')
6
7exports.needs = nest({
8 'app.html.sideNav': 'first',
9 'app.html.topNav': 'first',
10 'app.html.scroller': 'first',
11 'app.html.blogCard': 'first',
12 'blog.sync.isBlog': 'first',
13 'channel.html.subscribe': 'first',
14 'feed.pull.channel': 'first',
15 'history.sync.push': 'first',
16 'translations.sync.strings': 'first'
17})
18
19exports.create = (api) => {
20 return nest('app.page.channelShow', channelShow)
21
22 function channelShow (location) {
23 const strings = api.translations.sync.strings()
24 const { channel } = location
25
26 createStream = api.feed.pull.channel(channel)
27
28 const prepend = [
29 api.app.html.topNav(location),
30 h('section.about', [
31 h('h1', channel),
32 h('div.actions', [
33 api.channel.html.subscribe(channel)
34 ])
35 ])
36 ]
37
38 var channelPosts = api.app.html.scroller({
39 classList: ['content'],
40 prepend,
41 stream: createStream,
42 filter: () => pull(
43 pull.filter(api.blog.sync.isBlog),
44 pull.filter(msg => !msg.value.content.root) // show only root messages
45 ),
46 // FUTURE : if we need better perf, we can add a persistent cache. At the moment this page is fast enough though.
47 // See implementation of app.html.sideNav for example
48 // store: recentMsgCache,
49 // updateTop: updateRecentMsgCache,
50 // updateBottom: updateRecentMsgCache,
51 render
52 })
53
54 location.page = location.page || 'channelShow'
55 // covers case where router.sync.normalise delivers a loc = { channel: '#channelName' }
56 // HACK: helps sideNav
57
58 return h('Page -channelShow', { title: strings.home }, [
59 api.app.html.sideNav(location),
60 channelPosts
61 ])
62 }
63
64 function render (blog) {
65 const { recps, channel } = blog.value.content
66 var onClick
67 if (channel && !recps) { onClick = (ev) => api.history.sync.push(Object.assign({}, blog, { page: 'blogShow' })) }
68
69 return api.app.html.blogCard(blog, { onClick })
70 }
71}
72

Built with git-ssb-web