From 0e0984748a22eb93394cd1cf25c9a02b2db56a49 Mon Sep 17 00:00:00 2001 From: William Grant Date: Tue, 5 Sep 2023 11:37:19 +1000 Subject: [PATCH] fix: timer direction appears correctly on messages --- .../conversation/TimerNotification.tsx | 1 - .../message-item/ExpirableReadableMessage.tsx | 27 +++++++++---------- 2 files changed, 12 insertions(+), 16 deletions(-) diff --git a/ts/components/conversation/TimerNotification.tsx b/ts/components/conversation/TimerNotification.tsx index b88e4c20b..f9d422309 100644 --- a/ts/components/conversation/TimerNotification.tsx +++ b/ts/components/conversation/TimerNotification.tsx @@ -53,7 +53,6 @@ export const TimerNotification = (props: PropsForExpirationTimer) => { return ( & { messageId: string | undefined; @@ -23,7 +22,6 @@ function useIsExpired( const { convoId, messageId, - direction, expirationLength, expirationTimestamp, isExpired: isExpiredProps, @@ -36,7 +34,7 @@ function useIsExpired( const checkExpired = useCallback(async () => { const now = Date.now(); - if (!messageId || !direction || !expirationTimestamp || !expirationLength) { + if (!messageId || !expirationTimestamp || !expirationLength) { return; } @@ -55,7 +53,7 @@ function useIsExpired( convo?.updateLastMessage(); } } - }, [messageId, direction, expirationTimestamp, expirationLength, isExpired, convoId, dispatch]); + }, [messageId, expirationTimestamp, expirationLength, isExpired, convoId, dispatch]); let checkFrequency: number | null = null; if (expirationLength) { @@ -84,8 +82,6 @@ const StyledReadableMessage = styled(ReadableMessage)<{ export interface ExpirableReadableMessageProps extends Omit { messageId: string; - // Note: this direction is used to override the message model direction in cases where it isn't set i.e. Timer Notifications rely on the 'type' prop to determine direction - direction?: MessageModelType; isCentered?: boolean; marginInlineStart?: string; marginInlineEnd?: string; @@ -94,18 +90,12 @@ export interface ExpirableReadableMessageProps export const ExpirableReadableMessage = (props: ExpirableReadableMessageProps) => { const selected = useMessageExpirationPropsById(props.messageId); - const { - direction, - isCentered, - marginInlineStart = '6px', - marginInlineEnd = '6px', - dataTestId, - } = props; + const { isCentered, marginInlineStart = '6px', marginInlineEnd = '6px', dataTestId } = props; const { isExpired } = useIsExpired({ convoId: selected?.convoId, messageId: selected?.messageId, - direction: direction || selected?.direction, + direction: selected?.direction, expirationTimestamp: selected?.expirationTimestamp, expirationLength: selected?.expirationLength, isExpired: selected?.isExpired, @@ -115,7 +105,14 @@ export const ExpirableReadableMessage = (props: ExpirableReadableMessageProps) = return null; } - const { messageId, receivedAt, isUnread, expirationLength, expirationTimestamp } = selected; + const { + messageId, + direction, + receivedAt, + isUnread, + expirationLength, + expirationTimestamp, + } = selected; const isIncoming = direction === 'incoming';