From 17272858aaf09eac5a3550b23e97f8d339847bd9 Mon Sep 17 00:00:00 2001
From: crupest <crupest@outlook.com>
Date: Sat, 13 Feb 2021 16:18:50 +0800
Subject: ...

---
 .../views/timeline-common/TimelinePageTemplateUI.tsx   | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)

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

diff --git a/FrontEnd/src/app/views/timeline-common/TimelinePageTemplateUI.tsx b/FrontEnd/src/app/views/timeline-common/TimelinePageTemplateUI.tsx
index b0d3fe97..48263486 100644
--- a/FrontEnd/src/app/views/timeline-common/TimelinePageTemplateUI.tsx
+++ b/FrontEnd/src/app/views/timeline-common/TimelinePageTemplateUI.tsx
@@ -7,7 +7,7 @@ import { getAlertHost } from "@/services/alert";
 import { HttpTimelineInfo } from "@/http/timeline";
 
 import Timeline from "./Timeline";
-import TimelinePostEdit, { TimelinePostSendCallback } from "./TimelinePostEdit";
+import TimelinePostEdit from "./TimelinePostEdit";
 
 export interface TimelineCardComponentProps<TManageItems> {
   timeline: HttpTimelineInfo;
@@ -25,16 +25,17 @@ export interface TimelinePageTemplateUIOperations<TManageItems> {
   onMember: () => void;
   onBookmark?: () => void;
   onHighlight?: () => void;
-  onPost?: TimelinePostSendCallback;
 }
 
 export interface TimelinePageTemplateUIProps<TManageItems> {
-  timeline?:
+  timeline:
     | (HttpTimelineInfo & {
         operations: TimelinePageTemplateUIOperations<TManageItems>;
       })
     | "notexist"
-    | "offline";
+    | "offline"
+    | "loading"
+    | "error";
   notExistMessageI18nKey: string;
   CardComponent: React.ComponentType<TimelineCardComponentProps<TManageItems>>;
 }
@@ -90,7 +91,7 @@ export default function TimelinePageTemplateUI<TManageItems>(
 
   let body: React.ReactElement;
 
-  if (timeline == null) {
+  if (timeline == "loading") {
     body = (
       <div className="full-viewport-center-child">
         <Spinner variant="primary" animation="grow" />
@@ -101,6 +102,9 @@ export default function TimelinePageTemplateUI<TManageItems>(
     body = <p className="text-danger">Offline!</p>;
   } else if (timeline === "notexist") {
     body = <p className="text-danger">{t(props.notExistMessageI18nKey)}</p>;
+  } else if (timeline === "error") {
+    // TODO: i18n
+    body = <p className="text-danger">Error!</p>;
   } else {
     const { operations } = timeline;
     body = (
@@ -120,7 +124,7 @@ export default function TimelinePageTemplateUI<TManageItems>(
         >
           <Timeline timelineName={timeline.name} />
         </div>
-        {operations.onPost != null ? (
+        {timeline.postable ? (
           <>
             <div
               style={{ height: bottomSpaceHeight }}
@@ -128,7 +132,7 @@ export default function TimelinePageTemplateUI<TManageItems>(
             />
             <TimelinePostEdit
               className="fixed-bottom"
-              onPost={operations.onPost}
+              timeline={timeline}
               onHeightChange={onPostEditHeightChange}
               timelineUniqueId={timeline.uniqueId}
             />
-- 
cgit v1.2.3

