From: Dessalines Date: Wed, 15 Jan 2020 22:28:59 +0000 (-0500) Subject: Fix new post fetching. Fixes #422 X-Git-Url: http://these/git/%7B%60%24%7BwebArchiveUrl%7D/%22%7B%7D/readmes/%7B%7D/%22%7Burl%7D/%7BpictrsAvatarThumbnail%28?a=commitdiff_plain;h=9845fda05c94b01f1b46ac1e1be87e899b3a24d3;p=lemmy.git Fix new post fetching. Fixes #422 --- diff --git a/ui/src/components/community.tsx b/ui/src/components/community.tsx index 712aeb7e..6bcd88b1 100644 --- a/ui/src/components/community.tsx +++ b/ui/src/components/community.tsx @@ -89,14 +89,7 @@ export class Community 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), @@ -154,7 +147,7 @@ export class Community extends Component { )} {this.selects()} - + {this.state.posts && } {this.paginator()}
@@ -285,6 +278,11 @@ export class Community extends Component { this.setState(this.state); } else if (op == UserOperation.GetPosts) { let res: GetPostsResponse = msg; + + // This is needed to refresh the view + this.state.posts = undefined; + this.setState(this.state); + this.state.posts = res.posts; this.state.loading = false; this.setState(this.state); diff --git a/ui/src/components/main.tsx b/ui/src/components/main.tsx index 373889f9..9e7d690d 100644 --- a/ui/src/components/main.tsx +++ b/ui/src/components/main.tsx @@ -112,14 +112,7 @@ export class Main extends Component { this.handleTypeChange = this.handleTypeChange.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), @@ -429,7 +422,9 @@ export class Main extends Component { ) : (
{this.selects()} - + {this.state.posts && ( + + )} {this.paginator()}
)} @@ -601,6 +596,11 @@ export class Main extends Component { this.setState(this.state); } else if (op == UserOperation.GetPosts) { let res: GetPostsResponse = msg; + + // This is needed to refresh the view + this.state.posts = undefined; + this.setState(this.state); + this.state.posts = res.posts; this.state.loading = false; this.setState(this.state);