diff options
author | crupest <crupest@outlook.com> | 2020-08-25 00:05:01 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-08-25 00:05:01 +0800 |
commit | 738a17688ca481db62755295f8b732200ca12511 (patch) | |
tree | 034b470eff54a9f725cd9e472966cf554cd2ee26 /Timeline/ClientApp/src/app/home/BoardWithoutUser.tsx | |
parent | b9b7334ac5d5cf83b6206af024ddd4c55a6e07da (diff) | |
parent | fe687f82d9c5af2869b679222bec11b1a00b9ee9 (diff) | |
download | timeline-738a17688ca481db62755295f8b732200ca12511.tar.gz timeline-738a17688ca481db62755295f8b732200ca12511.tar.bz2 timeline-738a17688ca481db62755295f8b732200ca12511.zip |
Merge pull request #154 from crupest/toolchain
Upgrade toolchain of front end.
Diffstat (limited to 'Timeline/ClientApp/src/app/home/BoardWithoutUser.tsx')
-rw-r--r-- | Timeline/ClientApp/src/app/home/BoardWithoutUser.tsx | 121 |
1 files changed, 60 insertions, 61 deletions
diff --git a/Timeline/ClientApp/src/app/home/BoardWithoutUser.tsx b/Timeline/ClientApp/src/app/home/BoardWithoutUser.tsx index 4b30fcc4..972c1b25 100644 --- a/Timeline/ClientApp/src/app/home/BoardWithoutUser.tsx +++ b/Timeline/ClientApp/src/app/home/BoardWithoutUser.tsx @@ -1,61 +1,60 @@ -import React from 'react';
-import { Row, Col } from 'reactstrap';
-
-import { TimelineInfo } from '../data/timeline';
-
-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]);
-
- return (
- <Row className="my-2 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>
- )}
- </Row>
- );
-};
-
-export default BoardWithoutUser;
+import React from "react"; +import { Row, Col } from "reactstrap"; + +import { TimelineInfo } from "../data/timeline"; +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]); + + return ( + <Row className="my-2 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> + )} + </Row> + ); +}; + +export default BoardWithoutUser; |