Commit bcab6baed6e2bb6bf5d3ddbb628440027b68ef2c
remove comments, disable "Show More" button when you get to the bottom
Dominic Tarr committed on 8/14/2017, 8:04:21 AMParent: 08bdd1675bfb45b44e82c17c1269c2aafd4ae82b
Files changed
app/page/channel.js | changed |
app/page/channel.js | ||
---|---|---|
@@ -9,8 +9,9 @@ | ||
9 | 9 | const More = require('hypermore') |
10 | 10 | const morphdom = require('morphdom') |
11 | 11 | const Debounce = require('obv-debounce') |
12 | 12 | const PullObv = require('pull-obv') |
13 | +const Computed = require('mutant/computed') | |
13 | 14 | |
14 | 15 | exports.gives = nest('app.page.channel') |
15 | 16 | |
16 | 17 | exports.needs = nest({ |
@@ -60,33 +61,22 @@ | ||
60 | 61 | else return true |
61 | 62 | } |
62 | 63 | |
63 | 64 | var morePlease = false |
64 | - var threadsObs = api.state.obs.threads() | |
65 | 65 | |
66 | 66 | var createChannelStream = api.feed.pull.channel(location.channel) |
67 | 67 | |
68 | 68 | var channelObs = PullObv( |
69 | 69 | threadReduce, |
70 | 70 | createChannelStream({reverse: true, limit: 1000}) |
71 | 71 | ) |
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 | -// } | |
86 | 72 | |
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 | + | |
87 | 78 | var threadsHtmlObs = More( |
88 | -// threadsObsDebounced, | |
89 | 79 | channelObs, |
90 | 80 | function render (threads) { |
91 | 81 | |
92 | 82 | var sorted = Object.keys(threads.roots) |
@@ -96,9 +86,8 @@ | ||
96 | 86 | .sort(function (a, b) { |
97 | 87 | return latestUpdate(b) - latestUpdate(a) |
98 | 88 | }) |
99 | 89 | |
100 | - | |
101 | 90 | function latestUpdate(thread) { |
102 | 91 | var m = thread.timestamp |
103 | 92 | if(!thread.replies) return m |
104 | 93 | |
@@ -131,10 +120,12 @@ | ||
131 | 120 | return h('Page -home', [ |
132 | 121 | h('h1', location.channel), |
133 | 122 | api.app.html.nav(), |
134 | 123 | threadsHtmlObs, |
135 | - h('button', {'ev-click': threadsHtmlObs.more}, [strings.showMore]) | |
124 | + h('button', { | |
125 | + 'ev-click': threadsHtmlObs.more, | |
126 | + disabled: disableShowMore | |
127 | + }, [strings.showMore]) | |
136 | 128 | ]) |
137 | 129 | }) |
138 | 130 | } |
139 | 131 | |
140 | - |
Built with git-ssb-web