diff options
author | crupest <crupest@outlook.com> | 2023-07-20 20:44:15 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2023-07-20 20:44:15 +0800 |
commit | 0e183074b326cf04a23ae1f1ba8dcc56166df485 (patch) | |
tree | 87963dbe54b018ee0573cd77e674d32c23d8ba7f /FrontEnd/src/views/home/index.tsx | |
parent | adc91a81fe53fdbc3d63065baa0b56862c104824 (diff) | |
download | timeline-0e183074b326cf04a23ae1f1ba8dcc56166df485.tar.gz timeline-0e183074b326cf04a23ae1f1ba8dcc56166df485.tar.bz2 timeline-0e183074b326cf04a23ae1f1ba8dcc56166df485.zip |
...
Diffstat (limited to 'FrontEnd/src/views/home/index.tsx')
-rw-r--r-- | FrontEnd/src/views/home/index.tsx | 78 |
1 files changed, 0 insertions, 78 deletions
diff --git a/FrontEnd/src/views/home/index.tsx b/FrontEnd/src/views/home/index.tsx deleted file mode 100644 index 3c80fb0c..00000000 --- a/FrontEnd/src/views/home/index.tsx +++ /dev/null @@ -1,78 +0,0 @@ -import * as React from "react"; -import { useNavigate } from "react-router-dom"; - -import { highlightTimelineUsername } from "@/common"; - -import { Page } from "@/http/common"; -import { getHttpBookmarkClient, TimelineBookmark } from "@/http/bookmark"; - -import SearchInput from "../common/SearchInput"; -import TimelineListView from "./TimelineListView"; -import WebsiteIntroduction from "./WebsiteIntroduction"; - -import "./index.css"; - -const highlightTimelineMessageMap = { - loading: "home.loadingHighlightTimelines", - done: "home.loadedHighlightTimelines", - error: "home.errorHighlightTimelines", -} as const; - -const HomeV2: React.FC = () => { - const navigate = useNavigate(); - - const [navText, setNavText] = React.useState<string>(""); - - const [highlightTimelineState, setHighlightTimelineState] = React.useState< - "loading" | "done" | "error" - >("loading"); - const [highlightTimelines, setHighlightTimelines] = React.useState< - Page<TimelineBookmark> | undefined - >(); - - React.useEffect(() => { - if (highlightTimelineState === "loading") { - let subscribe = true; - void getHttpBookmarkClient() - .list(highlightTimelineUsername) - .then( - (data) => { - if (subscribe) { - setHighlightTimelineState("done"); - setHighlightTimelines(data); - } - }, - () => { - if (subscribe) { - setHighlightTimelineState("error"); - setHighlightTimelines(undefined); - } - } - ); - return () => { - subscribe = false; - }; - } - }, [highlightTimelineState]); - - return ( - <> - <SearchInput - className="mx-2 my-3 home-search" - value={navText} - onChange={setNavText} - onButtonClick={() => { - navigate(`search?q=${navText}`); - }} - alwaysOneline - /> - <WebsiteIntroduction className="m-2" /> - <TimelineListView - headerText={highlightTimelineMessageMap[highlightTimelineState]} - timelines={highlightTimelines?.items} - /> - </> - ); -}; - -export default HomeV2; |