git ssb

2+

mixmix / ticktack



Tree: 9de2656efd585098ef7eb72d618684bd03e34c37

Files: 9de2656efd585098ef7eb72d618684bd03e34c37 / app / page / blogIndex.js

1784 bytesRaw
1const nest = require('depnest')
2const { h } = require('mutant')
3const pull = require('pull-stream')
4
5exports.gives = nest('app.page.blogIndex')
6
7exports.needs = nest({
8 'app.html.context': 'first',
9 'app.html.blogCard': 'first',
10 'app.html.blogNav': 'first',
11 'app.html.scroller': 'first',
12 'feed.pull.public': 'first',
13 'history.sync.push': 'first',
14 'keys.sync.id': 'first',
15 'translations.sync.strings': 'first',
16 'unread.sync.isUnread': 'first'
17})
18
19exports.create = (api) => {
20 return nest('app.page.blogIndex', function (location) {
21 // location here can expected to be: { page: 'blogIndex'}
22
23 var strings = api.translations.sync.strings()
24
25 var blogs = api.app.html.scroller({
26 classList: ['content'],
27 prepend: api.app.html.blogNav(location),
28 stream: api.feed.pull.public,
29 filter: () => pull(
30 pull.filter(msg => {
31 const type = msg.value.content.type
32 return type === 'post' || type === 'blog'
33 }),
34 pull.filter(msg => !msg.value.content.root) // show only root messages
35 ),
36 // FUTURE : if we need better perf, we can add a persistent cache. At the moment this page is fast enough though.
37 // See implementation of app.html.context for example
38 // store: recentMsgCache,
39 // updateTop: updateRecentMsgCache,
40 // updateBottom: updateRecentMsgCache,
41 render
42 })
43
44 return h('Page -blogIndex', {title: strings.home}, [
45 api.app.html.context(location),
46 blogs
47 ])
48 })
49
50
51
52 function render (blog) {
53 const { recps, channel } = blog.value.content
54 var onClick
55 if (channel && !recps)
56 onClick = (ev) => api.history.sync.push(Object.assign({}, blog, { page: 'blogShow' }))
57
58 return api.app.html.blogCard(blog, { onClick })
59 }
60}
61
62

Built with git-ssb-web