diff options
author | crupest <crupest@outlook.com> | 2020-11-11 21:02:15 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2020-11-11 21:02:15 +0800 |
commit | eb75a01f00ff9ba34ef95b9d96e1c4141b3f08fb (patch) | |
tree | f36a8e62cf17323ab6d1c8f9e1be598c55f39f00 /FrontEnd/src/app/views/timeline-common/Timeline.tsx | |
parent | d3a9a1ca377dbc9d5ff641470407d30924bb5e34 (diff) | |
download | timeline-eb75a01f00ff9ba34ef95b9d96e1c4141b3f08fb.tar.gz timeline-eb75a01f00ff9ba34ef95b9d96e1c4141b3f08fb.tar.bz2 timeline-eb75a01f00ff9ba34ef95b9d96e1c4141b3f08fb.zip |
refactor: Refactor timeline props.
Diffstat (limited to 'FrontEnd/src/app/views/timeline-common/Timeline.tsx')
-rw-r--r-- | FrontEnd/src/app/views/timeline-common/Timeline.tsx | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/FrontEnd/src/app/views/timeline-common/Timeline.tsx b/FrontEnd/src/app/views/timeline-common/Timeline.tsx index ff9f663a..aba868cb 100644 --- a/FrontEnd/src/app/views/timeline-common/Timeline.tsx +++ b/FrontEnd/src/app/views/timeline-common/Timeline.tsx @@ -7,7 +7,7 @@ import TimelineItem from "./TimelineItem"; import TimelineTop from "./TimelineTop"; export interface TimelinePostInfoEx extends TimelinePostInfo { - deletable: boolean; + onDelete?: () => void; } export type TimelineDeleteCallback = (index: number, id: number) => void; @@ -16,13 +16,12 @@ export interface TimelineProps { className?: string; style?: React.CSSProperties; posts: TimelinePostInfoEx[]; - onDelete: TimelineDeleteCallback; onResize?: () => void; containerRef?: React.Ref<HTMLDivElement>; } const Timeline: React.FC<TimelineProps> = (props) => { - const { posts, onDelete, onResize } = props; + const { posts, onResize } = props; const [showMoreIndex, setShowMoreIndex] = React.useState<number>(-1); @@ -42,12 +41,12 @@ const Timeline: React.FC<TimelineProps> = (props) => { key={post.id} current={length - 1 === index} more={ - post.deletable + post.onDelete != null ? { isOpen: showMoreIndex === index, toggle: () => setShowMoreIndex((old) => (old === index ? -1 : index)), - onDelete: () => onDelete(index, post.id), + onDelete: post.onDelete, } : undefined } |