diff options
Diffstat (limited to 'FrontEnd')
3 files changed, 14 insertions, 20 deletions
diff --git a/FrontEnd/src/app/views/timeline-common/Timeline.tsx b/FrontEnd/src/app/views/timeline-common/Timeline.tsx index 2446c0dd..288be141 100644 --- a/FrontEnd/src/app/views/timeline-common/Timeline.tsx +++ b/FrontEnd/src/app/views/timeline-common/Timeline.tsx @@ -6,11 +6,12 @@ import { TimelinePostInfo, timelineService, } from "@/services/timeline"; +import { useUser } from "@/services/user"; +import { pushAlert } from "@/services/alert"; import TimelineItem from "./TimelineItem"; import TimelineTop from "./TimelineTop"; import TimelineDateItem from "./TimelineDateItem"; -import { useUser } from "@/services/user"; function dateEqual(left: Date, right: Date): boolean { return ( @@ -25,7 +26,6 @@ export interface TimelineProps { style?: React.CSSProperties; timeline: TimelineInfo; posts: TimelinePostInfo[]; - onDelete: (post: TimelinePostInfo) => void; } const Timeline: React.FC<TimelineProps> = (props) => { @@ -87,7 +87,17 @@ const Timeline: React.FC<TimelineProps> = (props) => { old === post.index ? -1 : post.index ), onDelete: () => { - props.onDelete(post); + timelineService + .deletePost(timeline.name, post.id) + .catch(() => { + pushAlert({ + type: "danger", + message: { + type: "i18n", + key: "timeline.deletePostFailed", + }, + }); + }); }, } : undefined diff --git a/FrontEnd/src/app/views/timeline-common/TimelinePageTemplate.tsx b/FrontEnd/src/app/views/timeline-common/TimelinePageTemplate.tsx index da020be4..bff4547e 100644 --- a/FrontEnd/src/app/views/timeline-common/TimelinePageTemplate.tsx +++ b/FrontEnd/src/app/views/timeline-common/TimelinePageTemplate.tsx @@ -1,5 +1,4 @@ import React from "react"; -import { useTranslation } from "react-i18next"; import { UiLogicError } from "@/common"; import { pushAlert } from "@/services/alert"; @@ -31,8 +30,6 @@ export interface TimelinePageTemplateProps<TManageItem> { export default function TimelinePageTemplate<TManageItem>( props: TimelinePageTemplateProps<TManageItem> ): React.ReactElement | null { - const { t } = useTranslation(); - const { name } = props; const service = timelineService; @@ -87,14 +84,6 @@ export default function TimelinePageTemplate<TManageItem>( return "notexist"; } else { const operations: TimelinePageTemplateUIOperations<TManageItem> = { - onDeletePost: (post) => { - service.deletePost(name, post.id).catch(() => { - pushAlert({ - type: "danger", - message: t("timeline.deletePostFailed"), - }); - }); - }, onPost: service.hasPostPermission(user, timeline) ? (req) => service.createPost(name, req).then(() => scrollToBottomNextSync()) diff --git a/FrontEnd/src/app/views/timeline-common/TimelinePageTemplateUI.tsx b/FrontEnd/src/app/views/timeline-common/TimelinePageTemplateUI.tsx index 815906d3..dbb47387 100644 --- a/FrontEnd/src/app/views/timeline-common/TimelinePageTemplateUI.tsx +++ b/FrontEnd/src/app/views/timeline-common/TimelinePageTemplateUI.tsx @@ -24,7 +24,6 @@ export interface TimelineCardComponentProps<TManageItems> { } export interface TimelinePageTemplateUIOperations<TManageItems> { - onDeletePost: (post: TimelinePostInfo) => void; onManage?: (item: TManageItems | "property") => void; onMember: () => void; onBookmark?: () => void; @@ -129,11 +128,7 @@ export default function TimelinePageTemplateUI<TManageItems>( minHeight: `calc(100vh - ${56 + bottomSpaceHeight}px)`, }} > - <Timeline - timeline={timeline} - posts={posts} - onDelete={operations.onDeletePost} - /> + <Timeline timeline={timeline} posts={posts} /> </div> ) ) : ( |