From c6e27d6d8845ffd35be26923851d80c04920fccb Mon Sep 17 00:00:00 2001 From: xmflsct Date: Mon, 5 Dec 2022 14:50:03 +0100 Subject: [PATCH] Fixed #514 --- src/components/Timeline/Default.tsx | 2 +- src/components/Timeline/Notifications.tsx | 9 ++++++--- src/components/Timeline/Shared/Actioned.tsx | 6 +++--- src/components/Timeline/Shared/Actions.tsx | 12 ++++++------ src/components/Timeline/Shared/Context.tsx | 2 +- src/components/Timeline/Shared/Poll.tsx | 15 +++++++++++---- 6 files changed, 28 insertions(+), 18 deletions(-) diff --git a/src/components/Timeline/Default.tsx b/src/components/Timeline/Default.tsx index 9676ad6b..cf57785b 100644 --- a/src/components/Timeline/Default.tsx +++ b/src/components/Timeline/Default.tsx @@ -120,7 +120,7 @@ const TimelineDefault: React.FC = ({ queryKey, rootQueryKey, status, - isReblog: !!item.reblog, + reblogStatus: item.reblog ? item : undefined, ownAccount, spoilerHidden, copiableContent, diff --git a/src/components/Timeline/Notifications.tsx b/src/components/Timeline/Notifications.tsx index 802ae3d5..04204965 100644 --- a/src/components/Timeline/Notifications.tsx +++ b/src/components/Timeline/Notifications.tsx @@ -38,7 +38,7 @@ const TimelineNotifications: React.FC = ({ }) => { const instanceAccount = useSelector(getInstanceAccount, () => true) - const status = notification.status + const status = notification.status?.reblog ? notification.status.reblog : notification.status const account = notification.status ? notification.status.account : notification.account const ownAccount = notification.account?.id === instanceAccount?.id const [spoilerExpanded, setSpoilerExpanded] = useState( @@ -78,7 +78,11 @@ const TimelineNotifications: React.FC = ({ return ( <> {notification.type !== 'mention' ? ( - + ) : null} = ({ value={{ queryKey, status, - isReblog: !!status?.reblog, ownAccount, spoilerHidden, copiableContent, diff --git a/src/components/Timeline/Shared/Actioned.tsx b/src/components/Timeline/Shared/Actioned.tsx index 2a5c8f86..fcc3a002 100644 --- a/src/components/Timeline/Shared/Actioned.tsx +++ b/src/components/Timeline/Shared/Actioned.tsx @@ -13,12 +13,12 @@ import StatusContext from './Context' export interface Props { action: Mastodon.Notification['type'] | 'reblog' | 'pinned' isNotification?: boolean - account?: Mastodon.Account + account?: Mastodon.Account // For notification } const TimelineActioned: React.FC = ({ action, isNotification, ...rest }) => { - const { status } = useContext(StatusContext) - const account = isNotification ? rest.account : status?.account + const { status, reblogStatus } = useContext(StatusContext) + const account = rest.account || (reblogStatus ? reblogStatus.account : status?.account) if (!status || !account) return null const { t } = useTranslation('componentTimeline') diff --git a/src/components/Timeline/Shared/Actions.tsx b/src/components/Timeline/Shared/Actions.tsx index 511cbaa9..0991ee89 100644 --- a/src/components/Timeline/Shared/Actions.tsx +++ b/src/components/Timeline/Shared/Actions.tsx @@ -22,7 +22,7 @@ import { useSelector } from 'react-redux' import StatusContext from './Context' const TimelineActions: React.FC = () => { - const { queryKey, rootQueryKey, status, isReblog, ownAccount, highlighted, disableDetails } = + const { queryKey, rootQueryKey, status, reblogStatus, ownAccount, highlighted, disableDetails } = useContext(StatusContext) if (!queryKey || !status || disableDetails) return null @@ -109,7 +109,7 @@ const TimelineActions: React.FC = () => { queryKey, rootQueryKey, id: status.id, - isReblog, + isReblog: !!reblogStatus, payload: { property: 'reblogged', currentValue: status.reblogged, @@ -125,7 +125,7 @@ const TimelineActions: React.FC = () => { queryKey, rootQueryKey, id: status.id, - isReblog, + isReblog: !!reblogStatus, payload: { property: 'reblogged', currentValue: status.reblogged, @@ -144,7 +144,7 @@ const TimelineActions: React.FC = () => { queryKey, rootQueryKey, id: status.id, - isReblog, + isReblog: !!reblogStatus, payload: { property: 'reblogged', currentValue: status.reblogged, @@ -161,7 +161,7 @@ const TimelineActions: React.FC = () => { queryKey, rootQueryKey, id: status.id, - isReblog, + isReblog: !!reblogStatus, payload: { property: 'favourited', currentValue: status.favourited, @@ -176,7 +176,7 @@ const TimelineActions: React.FC = () => { queryKey, rootQueryKey, id: status.id, - isReblog, + isReblog: !!reblogStatus, payload: { property: 'bookmarked', currentValue: status.bookmarked, diff --git a/src/components/Timeline/Shared/Context.tsx b/src/components/Timeline/Shared/Context.tsx index 5447643b..5dafee11 100644 --- a/src/components/Timeline/Shared/Context.tsx +++ b/src/components/Timeline/Shared/Context.tsx @@ -7,7 +7,7 @@ type ContextType = { status?: Mastodon.Status - isReblog?: boolean + reblogStatus?: Mastodon.Status // When it is a reblog, pass the root status ownAccount?: boolean spoilerHidden?: boolean copiableContent?: React.MutableRefObject<{ diff --git a/src/components/Timeline/Shared/Poll.tsx b/src/components/Timeline/Shared/Poll.tsx index 339b2fc5..6a21fcae 100644 --- a/src/components/Timeline/Shared/Poll.tsx +++ b/src/components/Timeline/Shared/Poll.tsx @@ -20,8 +20,15 @@ import { useQueryClient } from 'react-query' import StatusContext from './Context' const TimelinePoll: React.FC = () => { - const { queryKey, rootQueryKey, status, isReblog, ownAccount, spoilerHidden, disableDetails } = - useContext(StatusContext) + const { + queryKey, + rootQueryKey, + status, + reblogStatus, + ownAccount, + spoilerHidden, + disableDetails + } = useContext(StatusContext) if (!queryKey || !status || !status.poll) return null const poll = status.poll @@ -78,7 +85,7 @@ const TimelinePoll: React.FC = () => { queryKey, rootQueryKey, id: status.id, - isReblog, + isReblog: !!reblogStatus, payload: { property: 'poll', id: poll.id, @@ -104,7 +111,7 @@ const TimelinePoll: React.FC = () => { queryKey, rootQueryKey, id: status.id, - isReblog, + isReblog: !!reblogStatus, payload: { property: 'poll', id: poll.id,