Quellcode durchsuchen

BugFix RevisionLoader

Yuki Takei vor 6 Jahren
Ursprung
Commit
8c2c596178
2 geänderte Dateien mit 17 neuen und 12 gelöschten Zeilen
  1. 1 0
      CHANGES.md
  2. 16 12
      src/client/js/components/Page/RevisionLoader.jsx

+ 1 - 0
CHANGES.md

@@ -4,6 +4,7 @@
 
 * Improvement: Drop unnecessary MongoDB collection indexes
 * Improvement: Organize MongoDB collection indexes uniqueness
+* Fix: Search result or Timeline shows loading icon eternally when retrieving not accessible page
 
 ## 3.5.18
 

+ 16 - 12
src/client/js/components/Page/RevisionLoader.jsx

@@ -46,21 +46,25 @@ class RevisionLoader extends React.Component {
     };
 
     // load data with REST API
-    const res = await this.props.appContainer.apiGet('/revisions.get', requestData);
-    this.setState({ isLoaded: true, isLoading: false });
+    try {
+      const res = await this.props.appContainer.apiGet('/revisions.get', requestData);
 
-    if (res != null && !res.ok) {
-      throw new Error(res.error);
-    }
-
-    this.setState({
-      markdown: res.revision.body,
-      error: null,
-    });
+      this.setState({
+        markdown: res.revision.body,
+        error: null,
+      });
 
-    if (this.props.onRevisionLoaded != null) {
-      this.props.onRevisionLoaded(res.revision);
+      if (this.props.onRevisionLoaded != null) {
+        this.props.onRevisionLoaded(res.revision);
+      }
     }
+    catch (error) {
+      this.setState({ error });
+    }
+    finally {
+      this.setState({ isLoaded: true, isLoading: false });
+    }
+
   }
 
   onWaypointChange(event) {