Thread viewer for Bluesky

fixed pagination returning results of previous query

+1 -1
notifications_page.js
··· 13 let finished = false; 14 let cursor; 15 16 - loadInPages((next) => { 17 if (isLoading || finished) { return; } 18 isLoading = true; 19
··· 13 let finished = false; 14 let cursor; 15 16 + Paginator.loadInPages((next) => { 17 if (isLoading || finished) { return; } 18 isLoading = true; 19
+1 -1
private_search_page.js
··· 157 let cursor; 158 let finished = false; 159 160 - loadInPages(async () => { 161 if (isLoading || finished) { return; } 162 isLoading = true; 163
··· 157 let cursor; 158 let finished = false; 159 160 + Paginator.loadInPages(async () => { 161 if (isLoading || finished) { return; } 162 isLoading = true; 163
+2 -18
skythread.js
··· 341 let finished = false; 342 let cursor; 343 344 - loadInPages(() => { 345 if (isLoading || finished) { return; } 346 isLoading = true; 347 ··· 389 let cursor; 390 let finished = false; 391 392 - loadInPages(() => { 393 if (isLoading || finished) { return; } 394 isLoading = true; 395 ··· 440 }); 441 }); 442 } 443 - 444 - /** @param {Function} callback */ 445 - 446 - function loadInPages(callback) { 447 - let loadIfNeeded = () => { 448 - if (window.pageYOffset + window.innerHeight > document.body.offsetHeight - 500) { 449 - callback(loadIfNeeded); 450 - } 451 - }; 452 - 453 - callback(loadIfNeeded); 454 - 455 - document.addEventListener('scroll', loadIfNeeded); 456 - const resizeObserver = new ResizeObserver(loadIfNeeded); 457 - resizeObserver.observe(document.body); 458 - }
··· 341 let finished = false; 342 let cursor; 343 344 + Paginator.loadInPages(() => { 345 if (isLoading || finished) { return; } 346 isLoading = true; 347 ··· 389 let cursor; 390 let finished = false; 391 392 + Paginator.loadInPages(() => { 393 if (isLoading || finished) { return; } 394 isLoading = true; 395 ··· 440 }); 441 }); 442 }
+29
utils.js
··· 17 } 18 } 19 20 /** 21 * @template T 22 * @param {string} tag
··· 17 } 18 } 19 20 + window.Paginator = { 21 + /** @param {Function} callback */ 22 + 23 + loadInPages(callback) { 24 + if (this.scrollHandler) { 25 + document.removeEventListener('scroll', this.scrollHandler); 26 + } 27 + 28 + if (this.resizeObserver) { 29 + this.resizeObserver.disconnect(); 30 + } 31 + 32 + let loadIfNeeded = () => { 33 + if (window.pageYOffset + window.innerHeight > document.body.offsetHeight - 500) { 34 + callback(loadIfNeeded); 35 + } 36 + }; 37 + 38 + callback(loadIfNeeded); 39 + 40 + document.addEventListener('scroll', loadIfNeeded); 41 + const resizeObserver = new ResizeObserver(loadIfNeeded); 42 + resizeObserver.observe(document.body); 43 + 44 + this.scrollHandler = loadIfNeeded; 45 + this.resizeObserver = resizeObserver; 46 + } 47 + }; 48 + 49 /** 50 * @template T 51 * @param {string} tag