aboutsummaryrefslogtreecommitdiff
path: root/FrontEnd/src/app/views/home/BoardWithUser.tsx
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2020-12-19 22:04:25 +0800
committercrupest <crupest@outlook.com>2020-12-19 22:04:25 +0800
commit59b54e6e838b0b0f343ea917815f342b2987c417 (patch)
treeefcfc46da2fd6219fc32315246a7c781a366925b /FrontEnd/src/app/views/home/BoardWithUser.tsx
parentb1fcdac173457d2462836a8a749f3b2653be0e3a (diff)
downloadtimeline-59b54e6e838b0b0f343ea917815f342b2987c417.tar.gz
timeline-59b54e6e838b0b0f343ea917815f342b2987c417.tar.bz2
timeline-59b54e6e838b0b0f343ea917815f342b2987c417.zip
...
Diffstat (limited to 'FrontEnd/src/app/views/home/BoardWithUser.tsx')
-rw-r--r--FrontEnd/src/app/views/home/BoardWithUser.tsx61
1 files changed, 15 insertions, 46 deletions
diff --git a/FrontEnd/src/app/views/home/BoardWithUser.tsx b/FrontEnd/src/app/views/home/BoardWithUser.tsx
index 16648820..9b2f395d 100644
--- a/FrontEnd/src/app/views/home/BoardWithUser.tsx
+++ b/FrontEnd/src/app/views/home/BoardWithUser.tsx
@@ -3,61 +3,30 @@ import { Row, Col } from "react-bootstrap";
import { useTranslation } from "react-i18next";
import { AuthUser } from "@/services/user";
-import { TimelineInfo } from "@/services/timeline";
+import { getHttpHighlightClient } from "@/http/highlight";
import { getHttpTimelineClient } from "@/http/timeline";
import TimelineBoard from "./TimelineBoard";
-import OfflineBoard from "./OfflineBoard";
const BoardWithUser: React.FC<{ user: AuthUser }> = ({ user }) => {
const { t } = useTranslation();
- const [relatedTimelines, setRelatedTimelines] = React.useState<
- TimelineInfo[] | "offline" | "loading"
- >("loading");
-
- React.useEffect(() => {
- let subscribe = true;
- if (relatedTimelines === "loading") {
- void getHttpTimelineClient()
- .listTimeline({ relate: user.username })
- .then(
- (timelines) => {
- if (subscribe) {
- setRelatedTimelines(timelines);
- }
- },
- () => {
- setRelatedTimelines("offline");
- }
- );
- }
- return () => {
- subscribe = false;
- };
- }, [user, relatedTimelines]);
-
return (
<Row className="my-3 justify-content-center">
- {relatedTimelines === "offline" ? (
- <Col sm="8" lg="6">
- <OfflineBoard
- onReload={() => {
- setRelatedTimelines("loading");
- }}
- />
- </Col>
- ) : (
- <Col sm="6" lg="5">
- <TimelineBoard
- title={t("home.relatedTimeline")}
- timelines={relatedTimelines}
- onReload={() => {
- setRelatedTimelines("loading");
- }}
- />
- </Col>
- )}
+ <Col sm="6" lg="5">
+ <TimelineBoard
+ title={t("home.highlightTimeline")}
+ load={() => getHttpHighlightClient().list()}
+ />
+ </Col>
+ <Col sm="6" lg="5">
+ <TimelineBoard
+ title={t("home.relatedTimeline")}
+ load={() =>
+ getHttpTimelineClient().listTimeline({ relate: user.username })
+ }
+ />
+ </Col>
</Row>
);
};