git ssb

2+

mixmix / ticktack



Commit fb0788760b2ce15437b50ead1e804b650cc19077

disable debounce to prevent stacking of "load-content" effect on blogIndex

mix irving committed on 11/28/2017, 1:05:28 AM
Parent: 34736f8234e840203c81e10a3b49e1570aa2a801

Files changed

app/html/app.jschanged
app/page/blogIndex.jschanged
app/html/app.jsView
@@ -21,8 +21,9 @@
2121 var view = Value()
2222 var app = h('App', view)
2323 api.history.obs.location()(renderLocation)
2424 function renderLocation (loc) {
25+ console.log('rendering new view', loc)
2526 var page = api.router.sync.router(loc)
2627 if (page) view.set([
2728 api.app.html.header({location: loc, push: api.history.sync.push}),
2829 page
app/page/blogIndex.jsView
@@ -18,12 +18,12 @@
1818 'unread.sync.isUnread': 'first'
1919 })
2020
2121 exports.create = (api) => {
22- // var contentHtmlObs // TODO get a better cache than this
22+ var contentHtmlObs
2323
2424 return nest('app.page.blogIndex', function (location) {
25- // location here can expected to be: { page: 'blogIndex'}
25+ // location here can expected to be: { page: 'blogIndex'} or { page: 'home' }
2626 //
2727 var strings = api.translations.sync.strings()
2828 var blogs = blogsEl()
2929
@@ -37,29 +37,37 @@
3737 ])
3838 })
3939
4040 function blogsEl () {
41+ if (contentHtmlObs) return contentHtmlObs
4142 // TODO - replace with actual blogs
4243 var morePlease = false
44+
4345 var threadsObs = api.state.obs.threads()
46+ // var timestamp = new Date()
47+ // threadsObs(ev => console.log(timestamp, ev))
4448
49+ var threadsObsDebounced = threadsObs // TODO rename or fix debounce
50+
4551 // DUCT TAPE: debounce the observable so it doesn't
4652 // update the dom more than 1/second
47- threadsObs(function () {
48- if(morePlease) threadsObs.more()
49- })
50- threadsObsDebounced = Debounce(threadsObs, 1000)
51- threadsObsDebounced(function () {
52- morePlease = false
53- })
54- threadsObsDebounced.more = function () {
55- morePlease = true
56- requestIdleCallback(threadsObs.more)
57- }
53+ // threadsObs(function () {
54+ // console.log('blogs - update?', morePlease)
55+ // if(morePlease) threadsObs.more()
56+ // })
57+ // threadsObsDebounced = Debounce(threadsObs, 1000)
58+ // threadsObsDebounced(function () {
59+ // console.log('blogs - set morePlease: false')
60+ // morePlease = false
61+ // })
62+ // threadsObsDebounced.more = function () {
63+ // console.log('blogs - set morePlease: true', 'requestIdleCallback')
64+ // morePlease = true
65+ // requestIdleCallback(threadsObs.more)
66+ // }
5867
5968 var updates = h('div.blogs', [])
60- // contentHtmlObs = More(
61- var contentHtmlObs = More(
69+ contentHtmlObs = More(
6270 threadsObsDebounced,
6371 function render (threads) {
6472
6573 function latestUpdate(thread) {

Built with git-ssb-web