diff options
author | crupest <crupest@outlook.com> | 2021-02-20 15:19:58 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2021-02-20 15:25:52 +0800 |
commit | d83b2752de6fe465f9589efbcf7fd46e16bdb2cc (patch) | |
tree | e81138e85c33ffc9195e0e75c9ab31ebf44efc44 /FrontEnd/src/app/views/timeline-common/TimelinePageTemplate.tsx | |
parent | 1d3f97912b40f84a3ef826b3b8b39b74cb35c2f9 (diff) | |
download | timeline-d83b2752de6fe465f9589efbcf7fd46e16bdb2cc.tar.gz timeline-d83b2752de6fe465f9589efbcf7fd46e16bdb2cc.tar.bz2 timeline-d83b2752de6fe465f9589efbcf7fd46e16bdb2cc.zip |
fix: Fix reload logic.
Diffstat (limited to 'FrontEnd/src/app/views/timeline-common/TimelinePageTemplate.tsx')
-rw-r--r-- | FrontEnd/src/app/views/timeline-common/TimelinePageTemplate.tsx | 16 |
1 files changed, 4 insertions, 12 deletions
diff --git a/FrontEnd/src/app/views/timeline-common/TimelinePageTemplate.tsx b/FrontEnd/src/app/views/timeline-common/TimelinePageTemplate.tsx index 62204ca8..704e51fb 100644 --- a/FrontEnd/src/app/views/timeline-common/TimelinePageTemplate.tsx +++ b/FrontEnd/src/app/views/timeline-common/TimelinePageTemplate.tsx @@ -3,11 +3,7 @@ import { useTranslation } from "react-i18next"; import { Container, Spinner } from "react-bootstrap"; import { HttpNetworkError, HttpNotFoundError } from "@/http/common"; -import { - getHttpTimelineClient, - HttpTimelineInfo, - HttpTimelinePostInfo, -} from "@/http/timeline"; +import { getHttpTimelineClient, HttpTimelineInfo } from "@/http/timeline"; import { getAlertHost } from "@/services/alert"; @@ -41,7 +37,9 @@ const TimelinePageTemplate: React.FC<TimelinePageTemplateProps> = (props) => { React.useEffect(() => { setTimeline("loading"); + }, [timelineName]); + React.useEffect(() => { let subscribe = true; void getHttpTimelineClient() .getTimeline(timelineName) @@ -77,11 +75,8 @@ const TimelinePageTemplate: React.FC<TimelinePageTemplateProps> = (props) => { const [timelineReloadKey, setTimelineReloadKey] = React.useState<number>(0); - const [newPosts, setNewPosts] = React.useState<HttpTimelinePostInfo[]>([]); - const reloadTimeline = (): void => { setTimelineReloadKey((old) => old + 1); - setNewPosts([]); }; const onPostEditHeightChange = React.useCallback((height: number): void => { @@ -154,7 +149,6 @@ const TimelinePageTemplate: React.FC<TimelinePageTemplateProps> = (props) => { timelineName={timeline.name} reloadKey={timelineReloadKey} onReload={reloadTimeline} - additionalPosts={newPosts} onLoad={scrollToBottom} /> </Container> @@ -168,9 +162,7 @@ const TimelinePageTemplate: React.FC<TimelinePageTemplateProps> = (props) => { className="fixed-bottom" timeline={timeline} onHeightChange={onPostEditHeightChange} - onPosted={(newPost) => { - setNewPosts((old) => [...old, newPost]); - }} + onPosted={reloadTimeline} /> </> ) : null} |