git ssb

2+

mixmix / ticktack



Commit bcab6baed6e2bb6bf5d3ddbb628440027b68ef2c

remove comments, disable "Show More" button when you get to the bottom

Dominic Tarr committed on 8/14/2017, 8:04:21 AM
Parent: 08bdd1675bfb45b44e82c17c1269c2aafd4ae82b

Files changed

app/page/channel.jschanged
app/page/channel.jsView
@@ -9,8 +9,9 @@
99 const More = require('hypermore')
1010 const morphdom = require('morphdom')
1111 const Debounce = require('obv-debounce')
1212 const PullObv = require('pull-obv')
13+const Computed = require('mutant/computed')
1314
1415 exports.gives = nest('app.page.channel')
1516
1617 exports.needs = nest({
@@ -60,33 +61,22 @@
6061 else return true
6162 }
6263
6364 var morePlease = false
64- var threadsObs = api.state.obs.threads()
6565
6666 var createChannelStream = api.feed.pull.channel(location.channel)
6767
6868 var channelObs = PullObv(
6969 threadReduce,
7070 createChannelStream({reverse: true, limit: 1000})
7171 )
72-
73-// // DUCT TAPE: debounce the observable so it doesn't
74-// // update the dom more than 1/second
75-// threadsObs(function () {
76-// if(morePlease) threadsObs.more()
77-// })
78-// threadsObsDebounced = Debounce(threadsObs, 1000)
79-// threadsObsDebounced(function () {
80-// morePlease = false
81-// })
82-// threadsObsDebounced.more = function () {
83-// morePlease = true
84-// requestIdleCallback(threadsObs.more)
85-// }
8672
73+ //disable "Show More" button when we are at the last thread.
74+ var disableShowMore = Computed([channelObs], function (threads) {
75+ return !!threads.ended
76+ })
77+
8778 var threadsHtmlObs = More(
88-// threadsObsDebounced,
8979 channelObs,
9080 function render (threads) {
9181
9282 var sorted = Object.keys(threads.roots)
@@ -96,9 +86,8 @@
9686 .sort(function (a, b) {
9787 return latestUpdate(b) - latestUpdate(a)
9888 })
9989
100-
10190 function latestUpdate(thread) {
10291 var m = thread.timestamp
10392 if(!thread.replies) return m
10493
@@ -131,10 +120,12 @@
131120 return h('Page -home', [
132121 h('h1', location.channel),
133122 api.app.html.nav(),
134123 threadsHtmlObs,
135- h('button', {'ev-click': threadsHtmlObs.more}, [strings.showMore])
124+ h('button', {
125+ 'ev-click': threadsHtmlObs.more,
126+ disabled: disableShowMore
127+ }, [strings.showMore])
136128 ])
137129 })
138130 }
139131
140-

Built with git-ssb-web