From 3bf8adf6e16ee4e448bf1b19d169690779615799 Mon Sep 17 00:00:00 2001 From: Josh Perez <60019601+josh-signal@users.noreply.github.com> Date: Wed, 5 Jul 2023 18:38:37 -0400 Subject: [PATCH] Adds logging for edit syncs processing --- ts/components/EditHistoryMessagesModal.tsx | 15 +++++++++++++++ ts/messageModifiers/Edits.ts | 21 ++++++--------------- ts/state/ducks/globalModals.ts | 1 + ts/state/smart/EditHistoryMessagesModal.tsx | 3 +++ 4 files changed, 25 insertions(+), 15 deletions(-) diff --git a/ts/components/EditHistoryMessagesModal.tsx b/ts/components/EditHistoryMessagesModal.tsx index d41bacd1ed48..d6d7039132eb 100644 --- a/ts/components/EditHistoryMessagesModal.tsx +++ b/ts/components/EditHistoryMessagesModal.tsx @@ -15,6 +15,7 @@ import { shouldNeverBeCalled } from '../util/shouldNeverBeCalled'; import { useTheme } from '../hooks/useTheme'; import { isSameDay } from '../util/timestamp'; import { TimelineDateHeader } from './conversation/TimelineDateHeader'; +import { drop } from '../util/drop'; export type PropsType = { closeEditHistoryModal: () => unknown; @@ -132,6 +133,13 @@ export function EditHistoryMessagesModal({ }; setDisplayLimitById(update); }} + onContextMenu={() => { + drop( + window.navigator.clipboard.writeText( + String(currentMessage.timestamp) + ) + ); + }} platform={platform} showLightbox={closeAndShowLightbox} showSpoiler={(messageId, data) => { @@ -188,6 +196,13 @@ export function EditHistoryMessagesModal({ }; setDisplayLimitById(update); }} + onContextMenu={() => { + drop( + window.navigator.clipboard.writeText( + String(messageAttributes.timestamp) + ) + ); + }} platform={platform} showLightbox={closeAndShowLightbox} showSpoiler={(messageId, data) => { diff --git a/ts/messageModifiers/Edits.ts b/ts/messageModifiers/Edits.ts index df2ddb26c832..1e697bfc139f 100644 --- a/ts/messageModifiers/Edits.ts +++ b/ts/messageModifiers/Edits.ts @@ -47,6 +47,8 @@ export function forMessage(message: MessageModel): Array { export async function onEdit(edit: EditAttributesType): Promise { edits.add(edit); + const logId = `Edits.onEdit(timestamp=${edit.message.timestamp};target=${edit.targetSentTimestamp})`; + try { // The conversation the edited message was in; we have to find it in the database // to to figure that out. @@ -57,11 +59,7 @@ export async function onEdit(edit: EditAttributesType): Promise { ); if (!targetConversation) { - log.info( - 'No target conversation for edit', - edit.fromId, - edit.targetSentTimestamp - ); + log.info(`${logId}: No target conversation`); return; } @@ -69,10 +67,7 @@ export async function onEdit(edit: EditAttributesType): Promise { // Do not await, since this can deadlock the queue drop( targetConversation.queueJob('Edits.onEdit', async () => { - log.info('Handling edit for', { - targetSentTimestamp: edit.targetSentTimestamp, - sentAt: edit.message.timestamp, - }); + log.info(`${logId}: Handling edit`); const messages = await window.Signal.Data.getMessagesBySentAt( edit.targetSentTimestamp @@ -86,11 +81,7 @@ export async function onEdit(edit: EditAttributesType): Promise { ); if (!targetMessage) { - log.info( - 'No message for edit', - edit.fromId, - edit.targetSentTimestamp - ); + log.info(`${logId}: No message`); return; } @@ -106,6 +97,6 @@ export async function onEdit(edit: EditAttributesType): Promise { }) ); } catch (error) { - log.error('Edits.onEdit error:', Errors.toLogFormat(error)); + log.error(`${logId} error:`, Errors.toLogFormat(error)); } } diff --git a/ts/state/ducks/globalModals.ts b/ts/state/ducks/globalModals.ts index df8f10a83b77..087047e0a18d 100644 --- a/ts/state/ducks/globalModals.ts +++ b/ts/state/ducks/globalModals.ts @@ -751,6 +751,7 @@ function copyOverMessageAttributesIntoEditHistory( ...messageAttributes, // Always take attachments from the edited message (they might be absent) attachments: undefined, + editMessageTimestamp: undefined, quote: undefined, preview: [], ...editedMessageAttributes, diff --git a/ts/state/smart/EditHistoryMessagesModal.tsx b/ts/state/smart/EditHistoryMessagesModal.tsx index 1eb966a8975e..15080f177de0 100644 --- a/ts/state/smart/EditHistoryMessagesModal.tsx +++ b/ts/state/smart/EditHistoryMessagesModal.tsx @@ -42,6 +42,9 @@ export function SmartEditHistoryMessagesModal(): JSX.Element { isEditedMessage: false, // Do not show the same reactions in the message history UI reactions: undefined, + // Make sure that the timestamp is the correct timestamp from attributes + // not the one that the selector derives. + timestamp: messageAttributes.timestamp, })); }, [messagesAttributes, messagePropsSelector]);