diff options
author | crupest <crupest@outlook.com> | 2021-02-13 21:55:47 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2021-02-13 21:55:47 +0800 |
commit | 2c3b2917c123708f39c1d5288b850a23f0e6042f (patch) | |
tree | e655a7d3b851ee3682db8895d13d2e688d180364 /FrontEnd/src/app/views/timeline-common/Timeline.tsx | |
parent | 50dbdde46eed6f2ff4c9691eea4414c1712af8e5 (diff) | |
download | timeline-2c3b2917c123708f39c1d5288b850a23f0e6042f.tar.gz timeline-2c3b2917c123708f39c1d5288b850a23f0e6042f.tar.bz2 timeline-2c3b2917c123708f39c1d5288b850a23f0e6042f.zip |
...
Diffstat (limited to 'FrontEnd/src/app/views/timeline-common/Timeline.tsx')
-rw-r--r-- | FrontEnd/src/app/views/timeline-common/Timeline.tsx | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/FrontEnd/src/app/views/timeline-common/Timeline.tsx b/FrontEnd/src/app/views/timeline-common/Timeline.tsx index d41588bb..07ca2924 100644 --- a/FrontEnd/src/app/views/timeline-common/Timeline.tsx +++ b/FrontEnd/src/app/views/timeline-common/Timeline.tsx @@ -15,10 +15,20 @@ export interface TimelineProps { timelineName: string; reloadKey: number; onReload: () => void; + additionalPosts?: HttpTimelinePostInfo[]; + onLoad?: () => void; } const Timeline: React.FC<TimelineProps> = (props) => { - const { timelineName, className, style, reloadKey, onReload } = props; + const { + timelineName, + className, + style, + reloadKey, + onReload, + additionalPosts, + onLoad, + } = props; const [posts, setPosts] = React.useState< | HttpTimelinePostInfo[] @@ -59,6 +69,12 @@ const Timeline: React.FC<TimelineProps> = (props) => { }; }, [timelineName, reloadKey]); + React.useEffect(() => { + if (Array.isArray(posts)) { + onLoad?.(); + } + }, [posts, additionalPosts, onLoad]); + switch (posts) { case "loading": return ( @@ -91,7 +107,12 @@ const Timeline: React.FC<TimelineProps> = (props) => { </div> ); default: - return <TimelinePostListView posts={posts} onReload={onReload} />; + return ( + <TimelinePostListView + posts={[...posts, ...(additionalPosts ?? [])]} + onReload={onReload} + /> + ); } }; |