diff options
author | crupest <crupest@outlook.com> | 2021-01-03 19:38:05 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-03 19:38:05 +0800 |
commit | 418d631528fdb581a384068719e9af5dbaa66740 (patch) | |
tree | 42e2c0396a16cb5fbaaae665a238a8a031bef7f0 /FrontEnd/src/app/views/home/BoardWithoutUser.tsx | |
parent | 4b3ae3edd9e8aceac5ff26ef137d2a8d686fe305 (diff) | |
parent | 8af803cb0da57af1355ad28cd056cb5dcf6d6915 (diff) | |
download | timeline-418d631528fdb581a384068719e9af5dbaa66740.tar.gz timeline-418d631528fdb581a384068719e9af5dbaa66740.tar.bz2 timeline-418d631528fdb581a384068719e9af5dbaa66740.zip |
Merge pull request #197 from crupest/front-dev
Front: Highlight and bookmark timeline and new home page.
Diffstat (limited to 'FrontEnd/src/app/views/home/BoardWithoutUser.tsx')
-rw-r--r-- | FrontEnd/src/app/views/home/BoardWithoutUser.tsx | 61 |
1 files changed, 17 insertions, 44 deletions
diff --git a/FrontEnd/src/app/views/home/BoardWithoutUser.tsx b/FrontEnd/src/app/views/home/BoardWithoutUser.tsx index 7e30f799..d9c7fcf4 100644 --- a/FrontEnd/src/app/views/home/BoardWithoutUser.tsx +++ b/FrontEnd/src/app/views/home/BoardWithoutUser.tsx @@ -1,58 +1,31 @@ import React from "react"; import { Row, Col } from "react-bootstrap"; +import { useTranslation } from "react-i18next"; -import { TimelineInfo } from "@/services/timeline"; +import { getHttpHighlightClient } from "@/http/highlight"; import { getHttpTimelineClient } from "@/http/timeline"; import TimelineBoard from "./TimelineBoard"; -import OfflineBoard from "./OfflineBoard"; const BoardWithoutUser: React.FC = () => { - const [publicTimelines, setPublicTimelines] = React.useState< - TimelineInfo[] | "offline" | "loading" - >("loading"); - - React.useEffect(() => { - let subscribe = true; - if (publicTimelines === "loading") { - void getHttpTimelineClient() - .listTimeline({ visibility: "Public" }) - .then( - (timelines) => { - if (subscribe) { - setPublicTimelines(timelines); - } - }, - () => { - setPublicTimelines("offline"); - } - ); - } - return () => { - subscribe = false; - }; - }, [publicTimelines]); + const { t } = useTranslation(); return ( <Row className="my-3 justify-content-center"> - {publicTimelines === "offline" ? ( - <Col sm="8" lg="6"> - <OfflineBoard - onReload={() => { - setPublicTimelines("loading"); - }} - /> - </Col> - ) : ( - <Col sm="8" lg="6"> - <TimelineBoard - timelines={publicTimelines} - onReload={() => { - setPublicTimelines("loading"); - }} - /> - </Col> - )} + <Col xs="12" md="6"> + <TimelineBoard + title={t("home.highlightTimeline")} + load={() => getHttpHighlightClient().list()} + /> + </Col> + <Col xs="12" md="6" className="my-3 my-md-0"> + <TimelineBoard + title={t("home.publicTimeline")} + load={() => + getHttpTimelineClient().listTimeline({ visibility: "Public" }) + } + /> + </Col> </Row> ); }; |