prevent spamming, fix #293

This commit is contained in:
Nicolas Constant 2020-06-14 03:48:30 -04:00
parent c30ba1483a
commit 82a4452a41
No known key found for this signature in database
GPG Key ID: 1E9F677FB01A5688
4 changed files with 34 additions and 5 deletions

View File

@ -66,8 +66,9 @@ export abstract class TimelineBase extends BrowseBase {
}
}
private scrolledErrorOccured = false;
protected scrolledToBottom() {
if (this.isLoading || this.maxReached) return;
if (this.isLoading || this.maxReached || this.scrolledErrorOccured) return;
this.isLoading = true;
this.isProcessingInfiniteScroll = true;
@ -86,6 +87,11 @@ export abstract class TimelineBase extends BrowseBase {
}
})
.catch((err: HttpErrorResponse) => {
this.scrolledErrorOccured = true;
setTimeout(() => {
this.scrolledErrorOccured = false;
}, 5000);
this.notificationService.notifyHttpError(err, this.account);
})
.then(() => {

View File

@ -87,8 +87,9 @@ export class DirectMessagesComponent extends BrowseBase {
}
}
private scrolledErrorOccured = false;
private scrolledToBottom() {
if (this.isLoading || this.maxReached) return;
if (this.isLoading || this.maxReached || this.scrolledErrorOccured) return;
const maxId = this.conversations[this.conversations.length - 1].conversation.last_status.id;
@ -108,6 +109,11 @@ export class DirectMessagesComponent extends BrowseBase {
}
})
.catch(err => {
this.scrolledErrorOccured = true;
setTimeout(() => {
this.scrolledErrorOccured = false;
}, 5000);
this.notificationService.notifyHttpError(err, this.account.info);
})
.then(() => {

View File

@ -94,8 +94,9 @@ export class NotificationsComponent extends BrowseBase {
}
}
private scrolledErrorOccured = false;
private scrolledToBottom() {
if (this.isLoading || this.maxReached || this.notifications.length === 0) return;
if (this.isLoading || this.maxReached || this.notifications.length === 0 || this.scrolledErrorOccured) return;
this.isLoading = true;
this.isProcessingInfiniteScroll = true;
@ -118,6 +119,11 @@ export class NotificationsComponent extends BrowseBase {
this.lastId = notifications[notifications.length - 1].id;
})
.catch(err => {
this.scrolledErrorOccured = true;
setTimeout(() => {
this.scrolledErrorOccured = false;
}, 5000);
this.notificationService.notifyHttpError(err, this.account.info);
})
.then(() => {

View File

@ -194,8 +194,9 @@ export class StreamNotificationsComponent extends BrowseBase {
}
}
private scrolledErrorOccured = false;
notificationsScrolledToBottom(): any {
if (this.isNotificationsLoading || this.notificationsMaxReached || this.notifications.length === 0)
if (this.isNotificationsLoading || this.notificationsMaxReached || this.notifications.length === 0 || this.scrolledErrorOccured)
return;
this.isNotificationsLoading = true;
@ -216,6 +217,11 @@ export class StreamNotificationsComponent extends BrowseBase {
this.lastNotificationId = result[result.length - 1].id;
})
.catch(err => {
this.scrolledErrorOccured = true;
setTimeout(() => {
this.scrolledErrorOccured = false;
}, 5000);
this.notificationService.notifyHttpError(err, this.account);
})
.then(() => {
@ -224,7 +230,7 @@ export class StreamNotificationsComponent extends BrowseBase {
}
mentionsScrolledToBottom(): any {
if (this.isMentionsLoading || this.mentionsMaxReached || this.mentions.length === 0)
if (this.isMentionsLoading || this.mentionsMaxReached || this.mentions.length === 0 || this.scrolledErrorOccured)
return;
this.isMentionsLoading = true;
@ -245,6 +251,11 @@ export class StreamNotificationsComponent extends BrowseBase {
this.lastMentionId = result[result.length - 1].id;
})
.catch(err => {
this.scrolledErrorOccured = true;
setTimeout(() => {
this.scrolledErrorOccured = false;
}, 5000);
this.notificationService.notifyHttpError(err, this.account);
})
.then(() => {