Show dates in edit history modal
This commit is contained in:
parent
9c6fb29edb
commit
8507afd0e4
3 changed files with 54 additions and 35 deletions
|
@ -13,6 +13,8 @@ import { Modal } from './Modal';
|
||||||
import { WidthBreakpoint } from './_util';
|
import { WidthBreakpoint } from './_util';
|
||||||
import { shouldNeverBeCalled } from '../util/shouldNeverBeCalled';
|
import { shouldNeverBeCalled } from '../util/shouldNeverBeCalled';
|
||||||
import { useTheme } from '../hooks/useTheme';
|
import { useTheme } from '../hooks/useTheme';
|
||||||
|
import { isSameDay } from '../util/timestamp';
|
||||||
|
import { TimelineDateHeader } from './conversation/TimelineDateHeader';
|
||||||
|
|
||||||
export type PropsType = {
|
export type PropsType = {
|
||||||
closeEditHistoryModal: () => unknown;
|
closeEditHistoryModal: () => unknown;
|
||||||
|
@ -55,7 +57,7 @@ const MESSAGE_DEFAULT_PROPS = {
|
||||||
scrollToQuotedMessage: shouldNeverBeCalled,
|
scrollToQuotedMessage: shouldNeverBeCalled,
|
||||||
shouldCollapseAbove: false,
|
shouldCollapseAbove: false,
|
||||||
shouldCollapseBelow: false,
|
shouldCollapseBelow: false,
|
||||||
shouldHideMetadata: true,
|
shouldHideMetadata: false,
|
||||||
showContactModal: shouldNeverBeCalled,
|
showContactModal: shouldNeverBeCalled,
|
||||||
showConversation: noop,
|
showConversation: noop,
|
||||||
showEditHistoryModal: shouldNeverBeCalled,
|
showEditHistoryModal: shouldNeverBeCalled,
|
||||||
|
@ -144,39 +146,56 @@ export function EditHistoryMessagesModal({
|
||||||
{i18n('icu:EditHistoryMessagesModal__title')}
|
{i18n('icu:EditHistoryMessagesModal__title')}
|
||||||
</h3>
|
</h3>
|
||||||
|
|
||||||
{pastEdits.map(messageAttributes => {
|
{pastEdits.map((messageAttributes, index) => {
|
||||||
const syntheticId = `${messageAttributes.id}.${messageAttributes.timestamp}`;
|
const syntheticId = `${messageAttributes.id}.${messageAttributes.timestamp}`;
|
||||||
|
|
||||||
return (
|
const previousItem = pastEdits[index - 1];
|
||||||
<Message
|
|
||||||
{...MESSAGE_DEFAULT_PROPS}
|
const shouldShowDateHeader = Boolean(
|
||||||
{...messageAttributes}
|
!previousItem ||
|
||||||
id={syntheticId}
|
// This comparison avoids strange header behavior for out-of-order messages.
|
||||||
containerElementRef={containerElementRef}
|
(messageAttributes.timestamp > previousItem.timestamp &&
|
||||||
displayLimit={displayLimitById[syntheticId]}
|
!isSameDay(previousItem.timestamp, messageAttributes.timestamp))
|
||||||
getPreferredBadge={getPreferredBadge}
|
);
|
||||||
|
const dateHeaderElement = shouldShowDateHeader ? (
|
||||||
|
<TimelineDateHeader
|
||||||
i18n={i18n}
|
i18n={i18n}
|
||||||
isSpoilerExpanded={revealedSpoilersById[syntheticId] || {}}
|
timestamp={messageAttributes.timestamp}
|
||||||
key={messageAttributes.timestamp}
|
|
||||||
kickOffAttachmentDownload={kickOffAttachmentDownload}
|
|
||||||
messageExpanded={(messageId, displayLimit) => {
|
|
||||||
const update = {
|
|
||||||
...displayLimitById,
|
|
||||||
[messageId]: displayLimit,
|
|
||||||
};
|
|
||||||
setDisplayLimitById(update);
|
|
||||||
}}
|
|
||||||
platform={platform}
|
|
||||||
showLightbox={closeAndShowLightbox}
|
|
||||||
showSpoiler={(messageId, data) => {
|
|
||||||
const update = {
|
|
||||||
...revealedSpoilersById,
|
|
||||||
[messageId]: data,
|
|
||||||
};
|
|
||||||
setRevealedSpoilersById(update);
|
|
||||||
}}
|
|
||||||
theme={theme}
|
|
||||||
/>
|
/>
|
||||||
|
) : null;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<React.Fragment key={messageAttributes.timestamp}>
|
||||||
|
{dateHeaderElement}
|
||||||
|
<Message
|
||||||
|
{...MESSAGE_DEFAULT_PROPS}
|
||||||
|
{...messageAttributes}
|
||||||
|
id={syntheticId}
|
||||||
|
containerElementRef={containerElementRef}
|
||||||
|
displayLimit={displayLimitById[syntheticId]}
|
||||||
|
getPreferredBadge={getPreferredBadge}
|
||||||
|
i18n={i18n}
|
||||||
|
isSpoilerExpanded={revealedSpoilersById[syntheticId] || {}}
|
||||||
|
kickOffAttachmentDownload={kickOffAttachmentDownload}
|
||||||
|
messageExpanded={(messageId, displayLimit) => {
|
||||||
|
const update = {
|
||||||
|
...displayLimitById,
|
||||||
|
[messageId]: displayLimit,
|
||||||
|
};
|
||||||
|
setDisplayLimitById(update);
|
||||||
|
}}
|
||||||
|
platform={platform}
|
||||||
|
showLightbox={closeAndShowLightbox}
|
||||||
|
showSpoiler={(messageId, data) => {
|
||||||
|
const update = {
|
||||||
|
...revealedSpoilersById,
|
||||||
|
[messageId]: data,
|
||||||
|
};
|
||||||
|
setRevealedSpoilersById(update);
|
||||||
|
}}
|
||||||
|
theme={theme}
|
||||||
|
/>
|
||||||
|
</React.Fragment>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -142,14 +142,14 @@ export function MessageMetadata({
|
||||||
} else {
|
} else {
|
||||||
timestampNode = (
|
timestampNode = (
|
||||||
<MessageTimestamp
|
<MessageTimestamp
|
||||||
i18n={i18n}
|
|
||||||
timestamp={timestamp}
|
|
||||||
direction={metadataDirection}
|
|
||||||
deletedForEveryone={deletedForEveryone}
|
deletedForEveryone={deletedForEveryone}
|
||||||
|
direction={metadataDirection}
|
||||||
|
i18n={i18n}
|
||||||
|
module="module-message__metadata__date"
|
||||||
|
timestamp={timestamp}
|
||||||
withImageNoCaption={withImageNoCaption}
|
withImageNoCaption={withImageNoCaption}
|
||||||
withSticker={isSticker}
|
withSticker={isSticker}
|
||||||
withTapToViewExpired={isTapToViewExpired}
|
withTapToViewExpired={isTapToViewExpired}
|
||||||
module="module-message__metadata__date"
|
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,7 +39,7 @@ export function SmartEditHistoryMessagesModal(): JSX.Element {
|
||||||
return messagesAttributes.map(messageAttributes => ({
|
return messagesAttributes.map(messageAttributes => ({
|
||||||
...messagePropsSelector(messageAttributes as MessageAttributesType),
|
...messagePropsSelector(messageAttributes as MessageAttributesType),
|
||||||
// Make sure the messages don't get an "edited" badge
|
// Make sure the messages don't get an "edited" badge
|
||||||
editHistory: undefined,
|
isEditedMessage: false,
|
||||||
// Do not show the same reactions in the message history UI
|
// Do not show the same reactions in the message history UI
|
||||||
reactions: undefined,
|
reactions: undefined,
|
||||||
}));
|
}));
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue