From 04c7f99f679d9bb95708c14d4f3b92c3d9b39837 Mon Sep 17 00:00:00 2001 From: Dessalines Date: Wed, 15 Jan 2020 16:20:54 -0500 Subject: [PATCH] Adding limits to inbox fetching. Fixes #420 --- ui/src/components/inbox.tsx | 15 ++++----------- ui/src/components/navbar.tsx | 20 +++++++++----------- 2 files changed, 13 insertions(+), 22 deletions(-) diff --git a/ui/src/components/inbox.tsx b/ui/src/components/inbox.tsx index 39109a5d..a302b834 100644 --- a/ui/src/components/inbox.tsx +++ b/ui/src/components/inbox.tsx @@ -14,7 +14,7 @@ import { CommentResponse, } from '../interfaces'; import { WebSocketService, UserService } from '../services'; -import { msgOp } from '../utils'; +import { msgOp, fetchLimit } from '../utils'; import { CommentNodes } from './comment-nodes'; import { SortSelect } from './sort-select'; import { i18n } from '../i18next'; @@ -58,14 +58,7 @@ export class Inbox extends Component { this.handleSortChange = this.handleSortChange.bind(this); this.subscription = WebSocketService.Instance.subject - .pipe( - retryWhen(errors => - errors.pipe( - delay(3000), - take(10) - ) - ) - ) + .pipe(retryWhen(errors => errors.pipe(delay(3000), take(10)))) .subscribe( msg => this.parseMessage(msg), err => console.error(err), @@ -279,7 +272,7 @@ export class Inbox extends Component { sort: SortType[this.state.sort], unread_only: this.state.unreadOrAll == UnreadOrAll.Unread, page: this.state.page, - limit: 9999, + limit: fetchLimit, }; WebSocketService.Instance.getReplies(repliesForm); @@ -287,7 +280,7 @@ export class Inbox extends Component { sort: SortType[this.state.sort], unread_only: this.state.unreadOrAll == UnreadOrAll.Unread, page: this.state.page, - limit: 9999, + limit: fetchLimit, }; WebSocketService.Instance.getUserMentions(userMentionsForm); } diff --git a/ui/src/components/navbar.tsx b/ui/src/components/navbar.tsx index f1c35b1f..9fa1e3dc 100644 --- a/ui/src/components/navbar.tsx +++ b/ui/src/components/navbar.tsx @@ -13,7 +13,12 @@ import { GetSiteResponse, Comment, } from '../interfaces'; -import { msgOp, pictshareAvatarThumbnail, showAvatars } from '../utils'; +import { + msgOp, + pictshareAvatarThumbnail, + showAvatars, + fetchLimit, +} from '../utils'; import { version } from '../version'; import { i18n } from '../i18next'; import { T } from 'inferno-i18next'; @@ -56,14 +61,7 @@ export class Navbar extends Component { }); this.wsSub = WebSocketService.Instance.subject - .pipe( - retryWhen(errors => - errors.pipe( - delay(3000), - take(10) - ) - ) - ) + .pipe(retryWhen(errors => errors.pipe(delay(3000), take(10)))) .subscribe( msg => this.parseMessage(msg), err => console.error(err), @@ -241,14 +239,14 @@ export class Navbar extends Component { sort: SortType[SortType.New], unread_only: true, page: 1, - limit: 9999, + limit: fetchLimit, }; let userMentionsForm: GetUserMentionsForm = { sort: SortType[SortType.New], unread_only: true, page: 1, - limit: 9999, + limit: fetchLimit, }; if (this.currentLocation !== '/inbox') { WebSocketService.Instance.getReplies(repliesForm);