From 5cb8f773183a46b7be6f0af14110a499432abba7 Mon Sep 17 00:00:00 2001 From: crupest Date: Sat, 9 Jan 2021 23:44:45 +0800 Subject: ... --- .../views/timeline-common/TimelineCardTemplate.tsx | 10 +++++-- .../views/timeline-common/TimelinePageTemplate.tsx | 14 ++++----- .../timeline-common/TimelinePageTemplateUI.tsx | 35 +++++++++++----------- .../src/app/views/timeline/TimelineInfoCard.tsx | 6 ++-- FrontEnd/src/app/views/user/UserInfoCard.tsx | 6 ++-- 5 files changed, 38 insertions(+), 33 deletions(-) (limited to 'FrontEnd/src') diff --git a/FrontEnd/src/app/views/timeline-common/TimelineCardTemplate.tsx b/FrontEnd/src/app/views/timeline-common/TimelineCardTemplate.tsx index b2b349bc..e62f76fa 100644 --- a/FrontEnd/src/app/views/timeline-common/TimelineCardTemplate.tsx +++ b/FrontEnd/src/app/views/timeline-common/TimelineCardTemplate.tsx @@ -10,7 +10,11 @@ import SyncStatusBadge from "../timeline-common/SyncStatusBadge"; import CollapseButton from "../timeline-common/CollapseButton"; export interface TimelineCardTemplateProps - extends Omit, "onManage" | "onMember"> { + extends Omit, "operations"> { + operations: Pick< + TimelineCardComponentProps<"">["operations"], + "onHighlight" | "onBookmark" + >; infoArea: React.ReactElement; manageArea: | { type: "member"; onMember: () => void } @@ -33,13 +37,13 @@ function TimelineCardTemplate({ collapse, infoArea, manageArea, - onBookmark, - onHighlight, + operations, toggleCollapse, syncStatus, className, }: TimelineCardTemplateProps): React.ReactElement | null { const { t } = useTranslation(); + const { onBookmark, onHighlight } = operations; return (
diff --git a/FrontEnd/src/app/views/timeline-common/TimelinePageTemplate.tsx b/FrontEnd/src/app/views/timeline-common/TimelinePageTemplate.tsx index 35b31ec2..f66d14e0 100644 --- a/FrontEnd/src/app/views/timeline-common/TimelinePageTemplate.tsx +++ b/FrontEnd/src/app/views/timeline-common/TimelinePageTemplate.tsx @@ -110,7 +110,7 @@ export default function TimelinePageTemplate( : undefined, })); - const others = { + const operations = { onPost: service.hasPostPermission(user, timeline) ? onPost : undefined, @@ -189,20 +189,20 @@ export default function TimelinePageTemplate( }; if (type === "cache") { - return [{ timeline, posts, ...others }, "syncing"]; + return [{ timeline, posts, operations }, "syncing"]; } else if (type === "offline") { - return [{ timeline, posts, ...others }, "offline"]; + return [{ timeline, posts, operations }, "offline"]; } else { if (postListState == null) { - return [{ timeline, posts, ...others }, "syncing"]; + return [{ timeline, posts, operations }, "syncing"]; } else { const { type: postListType } = postListState; if (postListType === "synced") { - return [{ timeline, posts, ...others }, "synced"]; + return [{ timeline, posts, operations }, "synced"]; } else if (postListType === "cache") { - return [{ timeline, posts, ...others }, "syncing"]; + return [{ timeline, posts, operations }, "syncing"]; } else if (postListType === "offline") { - return [{ timeline, posts, ...others }, "offline"]; + return [{ timeline, posts, operations }, "offline"]; } } } diff --git a/FrontEnd/src/app/views/timeline-common/TimelinePageTemplateUI.tsx b/FrontEnd/src/app/views/timeline-common/TimelinePageTemplateUI.tsx index 20ec6e43..b2824c84 100644 --- a/FrontEnd/src/app/views/timeline-common/TimelinePageTemplateUI.tsx +++ b/FrontEnd/src/app/views/timeline-common/TimelinePageTemplateUI.tsx @@ -13,14 +13,16 @@ import { TimelineSyncStatus } from "./SyncStatusBadge"; export interface TimelineCardComponentProps { timeline: TimelineInfo; - onManage?: (item: TManageItems | "property") => void; - onMember: () => void; - onBookmark?: () => void; - onHighlight?: () => void; - className?: string; - collapse: boolean; syncStatus: TimelineSyncStatus; + operations: { + onManage?: (item: TManageItems | "property") => void; + onMember: () => void; + onBookmark?: () => void; + onHighlight?: () => void; + }; + collapse: boolean; toggleCollapse: () => void; + className?: string; } export interface TimelinePageTemplateUIProps { @@ -28,11 +30,13 @@ export interface TimelinePageTemplateUIProps { | { timeline: TimelineInfo; posts?: TimelinePostInfoEx[]; - onManage?: (item: TManageItems | "property") => void; - onMember: () => void; - onBookmark?: () => void; - onHighlight?: () => void; - onPost?: TimelinePostSendCallback; + operations: { + onManage?: (item: TManageItems | "property") => void; + onMember: () => void; + onBookmark?: () => void; + onHighlight?: () => void; + onPost?: TimelinePostSendCallback; + }; } | I18nText; syncStatus: TimelineSyncStatus; @@ -155,10 +159,7 @@ export default function TimelinePageTemplateUI( (
)} - {data != null && data.onPost != null ? ( + {data != null && data.operations.onPost != null ? ( <>
( /> diff --git a/FrontEnd/src/app/views/timeline/TimelineInfoCard.tsx b/FrontEnd/src/app/views/timeline/TimelineInfoCard.tsx index f4dbb67d..920f504d 100644 --- a/FrontEnd/src/app/views/timeline/TimelineInfoCard.tsx +++ b/FrontEnd/src/app/views/timeline/TimelineInfoCard.tsx @@ -13,8 +13,8 @@ export type OrdinaryTimelineManageItem = "delete"; export type TimelineInfoCardProps = TimelineCardComponentProps; const TimelineInfoCard: React.FC = (props) => { - const { onMember, onManage, ...otherProps } = props; - const { timeline } = props; + const { timeline, operations } = props; + const { onManage, onMember } = operations; const avatar = useAvatar(timeline?.owner?.username); @@ -66,7 +66,7 @@ const TimelineInfoCard: React.FC = (props) => { }; } })()} - {...otherProps} + {...props} /> ); }; diff --git a/FrontEnd/src/app/views/user/UserInfoCard.tsx b/FrontEnd/src/app/views/user/UserInfoCard.tsx index f31a939f..01d2c096 100644 --- a/FrontEnd/src/app/views/user/UserInfoCard.tsx +++ b/FrontEnd/src/app/views/user/UserInfoCard.tsx @@ -13,8 +13,8 @@ export type PersonalTimelineManageItem = "avatar" | "nickname"; export type UserInfoCardProps = TimelineCardComponentProps; const UserInfoCard: React.FC = (props) => { - const { onMember, onManage, ...otherProps } = props; - const { timeline } = props; + const { timeline, operations } = props; + const { onManage, onMember } = operations; const avatar = useAvatar(timeline?.owner?.username); @@ -66,7 +66,7 @@ const UserInfoCard: React.FC = (props) => { }; } })()} - {...otherProps} + {...props} /> ); }; -- cgit v1.2.3