stop scrolling spam, fix #107

This commit is contained in:
Nicolas Constant 2020-04-18 17:04:26 -04:00
parent c83a464901
commit b848e28f11
No known key found for this signature in database
GPG Key ID: 1E9F677FB01A5688
1 changed files with 7 additions and 1 deletions

View File

@ -19,6 +19,7 @@ import { StatusWrapper } from '../../../models/common.model';
})
export class StreamStatusesComponent implements OnInit, OnDestroy {
isLoading = true;
private lastInfinityFetchReturnedNothing = false;
isThread = false;
displayError: string;
hasContentWarnings = false;
@ -255,7 +256,7 @@ export class StreamStatusesComponent implements OnInit, OnDestroy {
}
private scrolledToBottom() {
if (this.isLoading) return;
if (this.isLoading || this.lastInfinityFetchReturnedNothing) return;
this.isLoading = true;
this.isProcessingInfiniteScroll = true;
@ -272,6 +273,10 @@ export class StreamStatusesComponent implements OnInit, OnDestroy {
const wrapper = new StatusWrapper(cwPolicy.status, this.account, cwPolicy.applyCw, cwPolicy.hide);
this.statuses.push(wrapper);
}
if(!status || status.length === 0){
this.lastInfinityFetchReturnedNothing = true;
}
})
.catch((err: HttpErrorResponse) => {
this.notificationService.notifyHttpError(err, this.account);
@ -318,6 +323,7 @@ export class StreamStatusesComponent implements OnInit, OnDestroy {
private checkAndCleanUpStream(): void {
if (this.streamPositionnedAtTop && this.statuses.length > 3 * this.streamingService.nbStatusPerIteration) {
this.statuses.length = 2 * this.streamingService.nbStatusPerIteration;
this.lastInfinityFetchReturnedNothing = false;
}
if (this.bufferStream.length > 3 * this.streamingService.nbStatusPerIteration) {