]> Untitled Git - lemmy.git/commitdiff
Fix new post fetching. Fixes #422
authorDessalines <tyhou13@gmx.com>
Wed, 15 Jan 2020 22:28:59 +0000 (17:28 -0500)
committerDessalines <tyhou13@gmx.com>
Wed, 15 Jan 2020 22:28:59 +0000 (17:28 -0500)
ui/src/components/community.tsx
ui/src/components/main.tsx

index 712aeb7e582f3e5b1cb99cfefcdd23361ff5de00..6bcd88b1d03f74f68dfa14aa82e814be5a768e94 100644 (file)
@@ -89,14 +89,7 @@ export class Community extends Component<any, State> {
     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<any, State> {
                 )}
               </h5>
               {this.selects()}
-              <PostListings posts={this.state.posts} />
+              {this.state.posts && <PostListings posts={this.state.posts} />}
               {this.paginator()}
             </div>
             <div class="col-12 col-md-4">
@@ -285,6 +278,11 @@ export class Community extends Component<any, State> {
       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);
index 373889f9b0a319e475c07759b114e7e1217e116a..9e7d690dcf9d6358a5a8ef113dafc5d32251fe77 100644 (file)
@@ -112,14 +112,7 @@ export class Main extends Component<any, MainState> {
     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<any, MainState> {
         ) : (
           <div>
             {this.selects()}
-            <PostListings posts={this.state.posts} showCommunity />
+            {this.state.posts && (
+              <PostListings posts={this.state.posts} showCommunity />
+            )}
             {this.paginator()}
           </div>
         )}
@@ -601,6 +596,11 @@ export class Main extends Component<any, MainState> {
       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);