From 3f6dbd2bd0fc8c9439733c88f6c169ed28c2def7 Mon Sep 17 00:00:00 2001
From: crupest <crupest@outlook.com>
Date: Sun, 14 Feb 2021 17:29:11 +0800
Subject: ...

---
 .../app/views/timeline-common/TimelinePostContentView.tsx | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

(limited to 'FrontEnd/src/app/views/timeline-common/TimelinePostContentView.tsx')

diff --git a/FrontEnd/src/app/views/timeline-common/TimelinePostContentView.tsx b/FrontEnd/src/app/views/timeline-common/TimelinePostContentView.tsx
index 35d091af..2f5d3989 100644
--- a/FrontEnd/src/app/views/timeline-common/TimelinePostContentView.tsx
+++ b/FrontEnd/src/app/views/timeline-common/TimelinePostContentView.tsx
@@ -7,6 +7,7 @@ import { getHttpTimelineClient, HttpTimelinePostInfo } from "@/http/timeline";
 import { useUser } from "@/services/user";
 
 import Skeleton from "../common/Skeleton";
+import LoadFailReload from "../common/LoadFailReload";
 
 const TextView: React.FC<TimelinePostContentViewProps> = (props) => {
   const { post, className, style } = props;
@@ -14,6 +15,8 @@ const TextView: React.FC<TimelinePostContentViewProps> = (props) => {
   const [text, setText] = React.useState<string | null>(null);
   const [error, setError] = React.useState<"offline" | "error" | null>(null);
 
+  const [reloadKey, setReloadKey] = React.useState<number>(0);
+
   React.useEffect(() => {
     let subscribe = true;
 
@@ -40,14 +43,15 @@ const TextView: React.FC<TimelinePostContentViewProps> = (props) => {
     return () => {
       subscribe = false;
     };
-  }, [post.timelineName, post.id]);
+  }, [post.timelineName, post.id, reloadKey]);
 
   if (error != null) {
-    // TODO: i18n
     return (
-      <div className={className} style={style}>
-        Error!
-      </div>
+      <LoadFailReload
+        className={className}
+        style={style}
+        onReload={() => setReloadKey(reloadKey + 1)}
+      />
     );
   } else if (text == null) {
     return <Skeleton />;
@@ -109,6 +113,7 @@ const TimelinePostContentView: React.FC<TimelinePostContentViewProps> = (
     return <View post={post} className={className} style={style} />;
   } else {
     // TODO: i18n
+    console.error("Unknown post type", post);
     return <div>Error, unknown post type!</div>;
   }
 };
-- 
cgit v1.2.3

