git ssb

2+

mixmix / ticktack



Tree: 50a8f45832d95d56a26433d9cd66e7453416a55e

Files: 50a8f45832d95d56a26433d9cd66e7453416a55e / app / page / blogIndex.js

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

Built with git-ssb-web