git ssb

2+

mixmix / ticktack



Commit 17df3c936c4c4573ec97072a96be633ed3ae1c2b

wip

mix irving committed on 5/19/2018, 6:33:09 AM
Parent: c0dd626b0d708d6baff34a5f1e8fb399bc0119cd

Files changed

app/page/blogIndex.jschanged
app/page/blogIndex.jsView
@@ -1,14 +1,16 @@
11 const nest = require('depnest')
22 const { h, Value, Array: MutantArray, resolve } = require('mutant')
3 +const Scroller = require('mutant-scroll')
34 const pull = require('pull-stream')
5 +const Next = require('pull-next')
46
57 exports.gives = nest('app.page.blogIndex')
68
79 exports.needs = nest({
810 'app.html.blogCard': 'first',
911 'app.html.topNav': 'first',
10- 'app.html.scroller': 'first',
12 + // 'app.html.scroller': 'first',
1113 'app.html.sideNav': 'first',
1214 'blog.sync.isBlog': 'first',
1315 'feed.pull.public': 'first',
1416 'feed.pull.type': 'first',
@@ -26,23 +28,38 @@
2628 // location here can expected to be: { page: 'blogIndex'}
2729
2830 var strings = api.translations.sync.strings()
2931
30- var blogs = api.app.html.scroller({
32 + // const filter = () => pull(
33 + // pull.filter(api.blog.sync.isBlog), // isBlog or Plog?
34 + // pull.filter(msg => !msg.value.content.root), // show only root messages
35 + // pull.filter(msg => !api.message.sync.isBlocked(msg)) // this is already in feed.pull.type
36 + // )
37 +
38 + // stream: api.feed.pull.public, // for post + blog type
39 +
40 + const streamToTop = pull(
41 + // next(stream, { live: true, reverse: false, old: false, limit: 100, property: indexProperty }),
42 + api.feed.pull.type('blog')({ live: true, reverse: false, old: false }),
43 + // filter()
44 + )
45 +
46 +
47 + const streamToBottom = pull(
48 + Next
49 + api.feed.pull.type('blog')({ live: false, reverse: true }),
50 + // filter()
51 +
52 + )
53 +
54 + var blogs = Scroller({
3155 classList: ['content'],
3256 prepend: api.app.html.topNav(location),
33- // stream: api.feed.pull.public,
34- stream: api.feed.pull.type('blog'),
35- filter: () => pull(
36- // pull.filter(api.blog.sync.isBlog),
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.sideNav for example
42- store: blogsCache,
57 + streamToTop,
58 + streamToBottom,
4359 updateTop: update,
4460 updateBottom: update,
61 + store: blogsCache,
4562 render
4663 })
4764
4865 return h('Page -blogIndex', {title: strings.home}, [
@@ -52,10 +69,8 @@
5269 })
5370
5471 function update (soFar, newBlog) {
5572 soFar.transaction(() => {
56- const { timestamp } = newBlog.value
57-
5873 var object = newBlog // Value(newBlog)
5974
6075 const index = indexOf(soFar, (blog) => newBlog.key === resolve(blog).key)
6176 // if blog already in cache, not needed again
@@ -65,9 +80,9 @@
6580 const justOlderPosition = indexOf(soFar, (msg) => newBlog.timestamp > resolve(msg).timestamp)
6681
6782 // Orders by: time published BUT the messagesByType stream streams _by time received_
6883 // TODO - we need an index of all blogs otherwise the scroller doesn't work...
69- // const justOlderPosition = indexOf(soFar, (msg) => timestamp > resolve(msg).value.timestamp)
84 + // const justOlderPosition = indexOf(soFar, (msg) => newBlog.value.timestamp > resolve(msg).value.timestamp)
7085
7186 if (justOlderPosition > -1) {
7287 soFar.insert(object, justOlderPosition)
7388 } else {

Built with git-ssb-web