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
commit98132cee7e4c427cab4cec2af45e1b8102c59c3b (patch)
treebd27e78714bf5442956be2461f4338e44301c22e /FrontEnd/src/app/views/timeline-common/Timeline.tsx
parent3652e1c69f12b90b155bc73c3fe5a2ace9caf26c (diff)
downloadtimeline-98132cee7e4c427cab4cec2af45e1b8102c59c3b.tar.gz
timeline-98132cee7e4c427cab4cec2af45e1b8102c59c3b.tar.bz2
timeline-98132cee7e4c427cab4cec2af45e1b8102c59c3b.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
}