aboutsummaryrefslogtreecommitdiff
path: root/FrontEnd/src/app/views/timeline-common/Timeline.tsx
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2020-11-11 21:02:15 +0800
committercrupest <crupest@outlook.com>2020-11-11 21:02:15 +0800
commiteb75a01f00ff9ba34ef95b9d96e1c4141b3f08fb (patch)
treef36a8e62cf17323ab6d1c8f9e1be598c55f39f00 /FrontEnd/src/app/views/timeline-common/Timeline.tsx
parentd3a9a1ca377dbc9d5ff641470407d30924bb5e34 (diff)
downloadtimeline-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.tsx9
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
}