Commit 780b6c7547c81e9ac9c612627a555dbe8ccbf399
use throttle to slow down rendering new threads
Dominic Tarr committed on 12/8/2017, 5:03:35 AMParent: b763bdeb4867a9283ac98ff74113ac0dd62507f5
Files changed
app/html/comments.js | changed |
app/html/comments.js | ||
---|---|---|
@@ -1,6 +1,6 @@ | ||
1 | 1 | const nest = require('depnest') |
2 | -const { h, Array: MutantArray, Value, map, computed, when, resolve } = require('mutant') | |
2 | +const { h, Array: MutantArray, Value, map, computed, when, resolve, throttle } = require('mutant') | |
3 | 3 | const get = require('lodash/get') |
4 | 4 | |
5 | 5 | exports.gives = nest('app.html.comments') |
6 | 6 | |
@@ -23,9 +23,10 @@ | ||
23 | 23 | function comments (root) { |
24 | 24 | const { messages, channel, lastId: branch } = api.feed.obs.thread(root) |
25 | 25 | |
26 | 26 | // TODO - move this up into Patchcore |
27 | - const messagesTree = computed(messages, msgs => { | |
27 | + var debouncer = null | |
28 | + const messagesTree = computed(throttle(messages, 200), msgs => { | |
28 | 29 | return msgs |
29 | 30 | .filter(msg => forkOf(msg) === undefined) |
30 | 31 | .map(threadMsg => { |
31 | 32 | const nestedReplies = msgs.filter(msg => forkOf(msg) === threadMsg.key) |
@@ -137,4 +138,6 @@ | ||
137 | 138 | |
138 | 139 | function forkOf (msg) { |
139 | 140 | return get(msg, 'value.content.fork') |
140 | 141 | } |
142 | + | |
143 | + |
Built with git-ssb-web