From 1b156c5f56b69d5c470db4c546cba66f77f13632 Mon Sep 17 00:00:00 2001 From: Christopher Gurnee Date: Sat, 5 Mar 2022 09:58:14 -0500 Subject: [PATCH] Small update to c236bf3 This probably isn't fixing a bug, but better safe than sorry. --- src/pages/thread/index.js | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/src/pages/thread/index.js b/src/pages/thread/index.js index a1c1e2f..9e7f12b 100644 --- a/src/pages/thread/index.js +++ b/src/pages/thread/index.js @@ -35,9 +35,8 @@ class ChunkedQueue { this._chunks.push([x]) } - hasFullChunk() { - return this._chunks[0].length >= this._chunkSize - } + hasFullChunk = () => this._chunks[0].length >= this._chunkSize + isEmpty = () => this._chunks[0].length == 0 shiftChunk() { const first = this._chunks.shift() @@ -45,12 +44,6 @@ class ChunkedQueue { this._chunks.push([]) return first } - - shiftAll() { - const all = this._chunks.flat() - this._chunks = [[]] - return all - } } class Thread extends React.Component { @@ -217,7 +210,8 @@ class Thread extends React.Component { console.log('Pushshift:', lengths.reduce((a,b) => a+b, 0), 'comments') // All comments from Pushshift have been processed; wait for Reddit to finish - doRedditComments(redditIdQueue.shiftAll()) + while (!redditIdQueue.isEmpty()) + doRedditComments(redditIdQueue.shiftChunk()) Promise.all(redditPromises).then(lengths => { console.log('Reddit:', lengths.reduce((a,b) => a+b, 0), 'comments') if (!redditError) {