diff options
author | crupest <crupest@outlook.com> | 2020-12-19 21:42:58 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2020-12-19 21:42:58 +0800 |
commit | 72f07aeaf0be1ac9fcef627f1ab9f43cd5a4bc8d (patch) | |
tree | f1ca77d6bdefc1c0a22b64d4c1aac975e18a417b /FrontEnd/src | |
parent | 2adc29ac56167e5c46b8fecdd0eff8cbd9384378 (diff) | |
download | timeline-72f07aeaf0be1ac9fcef627f1ab9f43cd5a4bc8d.tar.gz timeline-72f07aeaf0be1ac9fcef627f1ab9f43cd5a4bc8d.tar.bz2 timeline-72f07aeaf0be1ac9fcef627f1ab9f43cd5a4bc8d.zip |
...
Diffstat (limited to 'FrontEnd/src')
-rw-r--r-- | FrontEnd/src/app/locales/en/translation.json | 1 | ||||
-rw-r--r-- | FrontEnd/src/app/locales/zh/translation.json | 1 | ||||
-rw-r--r-- | FrontEnd/src/app/views/home/BoardWithUser.tsx | 70 |
3 files changed, 19 insertions, 53 deletions
diff --git a/FrontEnd/src/app/locales/en/translation.json b/FrontEnd/src/app/locales/en/translation.json index cdb6da37..f07efafe 100644 --- a/FrontEnd/src/app/locales/en/translation.json +++ b/FrontEnd/src/app/locales/en/translation.json @@ -21,6 +21,7 @@ "home": { "go": "Go!", "allTimeline": "All Timelines", + "relatedTimeline": "Timelines Related To You", "joinTimeline": "Joined Timelines", "ownTimeline": "Owned Timelines", "offlinePrompt": "Oh oh, it seems you are offline. Here list some timelines cached locally. You can view them or click <1>here</1> to refresh.", diff --git a/FrontEnd/src/app/locales/zh/translation.json b/FrontEnd/src/app/locales/zh/translation.json index 5d28f694..5991f3cd 100644 --- a/FrontEnd/src/app/locales/zh/translation.json +++ b/FrontEnd/src/app/locales/zh/translation.json @@ -21,6 +21,7 @@ "home": { "go": "冲!", "allTimeline": "所有的时间线", + "relatedTimeline": "关于你的时间线", "joinTimeline": "加入的时间线", "ownTimeline": "拥有的时间线", "offlinePrompt": "你好像处于离线状态。以下是一些缓存在本地的时间线。你可以查看它们或者<1>点击</1>重新获取在线信息。", diff --git a/FrontEnd/src/app/views/home/BoardWithUser.tsx b/FrontEnd/src/app/views/home/BoardWithUser.tsx index bbef835a..16648820 100644 --- a/FrontEnd/src/app/views/home/BoardWithUser.tsx +++ b/FrontEnd/src/app/views/home/BoardWithUser.tsx @@ -12,87 +12,51 @@ import OfflineBoard from "./OfflineBoard"; const BoardWithUser: React.FC<{ user: AuthUser }> = ({ user }) => { const { t } = useTranslation(); - const [ownTimelines, setOwnTimelines] = React.useState< + const [relatedTimelines, setRelatedTimelines] = React.useState< TimelineInfo[] | "offline" | "loading" >("loading"); - const [joinTimelines, setJoinTimelines] = React.useState< - TimelineInfo[] | "offline" | "loading" - >("loading"); - - React.useEffect(() => { - let subscribe = true; - if (ownTimelines === "loading") { - void getHttpTimelineClient() - .listTimeline({ relate: user.username, relateType: "own" }) - .then( - (timelines) => { - if (subscribe) { - setOwnTimelines(timelines); - } - }, - () => { - setOwnTimelines("offline"); - } - ); - } - return () => { - subscribe = false; - }; - }, [user, ownTimelines]); React.useEffect(() => { let subscribe = true; - if (joinTimelines === "loading") { + if (relatedTimelines === "loading") { void getHttpTimelineClient() - .listTimeline({ relate: user.username, relateType: "join" }) + .listTimeline({ relate: user.username }) .then( (timelines) => { if (subscribe) { - setJoinTimelines(timelines); + setRelatedTimelines(timelines); } }, () => { - setJoinTimelines("offline"); + setRelatedTimelines("offline"); } ); } return () => { subscribe = false; }; - }, [user, joinTimelines]); + }, [user, relatedTimelines]); return ( <Row className="my-3 justify-content-center"> - {ownTimelines === "offline" && joinTimelines === "offline" ? ( + {relatedTimelines === "offline" ? ( <Col sm="8" lg="6"> <OfflineBoard onReload={() => { - setOwnTimelines("loading"); - setJoinTimelines("loading"); + setRelatedTimelines("loading"); }} /> </Col> ) : ( - <> - <Col sm="6" lg="5" className="mb-3 mb-sm-0"> - <TimelineBoard - title={t("home.ownTimeline")} - timelines={ownTimelines} - onReload={() => { - setOwnTimelines("loading"); - }} - /> - </Col> - <Col sm="6" lg="5"> - <TimelineBoard - title={t("home.joinTimeline")} - timelines={joinTimelines} - onReload={() => { - setJoinTimelines("loading"); - }} - /> - </Col> - </> + <Col sm="6" lg="5"> + <TimelineBoard + title={t("home.relatedTimeline")} + timelines={relatedTimelines} + onReload={() => { + setRelatedTimelines("loading"); + }} + /> + </Col> )} </Row> ); |