Adds logging for edit syncs processing

This commit is contained in:
Josh Perez 2023-07-05 18:38:37 -04:00 committed by GitHub
parent dda3bbc5b3
commit 3bf8adf6e1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 25 additions and 15 deletions

View file

@ -15,6 +15,7 @@ import { shouldNeverBeCalled } from '../util/shouldNeverBeCalled';
import { useTheme } from '../hooks/useTheme'; import { useTheme } from '../hooks/useTheme';
import { isSameDay } from '../util/timestamp'; import { isSameDay } from '../util/timestamp';
import { TimelineDateHeader } from './conversation/TimelineDateHeader'; import { TimelineDateHeader } from './conversation/TimelineDateHeader';
import { drop } from '../util/drop';
export type PropsType = { export type PropsType = {
closeEditHistoryModal: () => unknown; closeEditHistoryModal: () => unknown;
@ -132,6 +133,13 @@ export function EditHistoryMessagesModal({
}; };
setDisplayLimitById(update); setDisplayLimitById(update);
}} }}
onContextMenu={() => {
drop(
window.navigator.clipboard.writeText(
String(currentMessage.timestamp)
)
);
}}
platform={platform} platform={platform}
showLightbox={closeAndShowLightbox} showLightbox={closeAndShowLightbox}
showSpoiler={(messageId, data) => { showSpoiler={(messageId, data) => {
@ -188,6 +196,13 @@ export function EditHistoryMessagesModal({
}; };
setDisplayLimitById(update); setDisplayLimitById(update);
}} }}
onContextMenu={() => {
drop(
window.navigator.clipboard.writeText(
String(messageAttributes.timestamp)
)
);
}}
platform={platform} platform={platform}
showLightbox={closeAndShowLightbox} showLightbox={closeAndShowLightbox}
showSpoiler={(messageId, data) => { showSpoiler={(messageId, data) => {

View file

@ -47,6 +47,8 @@ export function forMessage(message: MessageModel): Array<EditAttributesType> {
export async function onEdit(edit: EditAttributesType): Promise<void> { export async function onEdit(edit: EditAttributesType): Promise<void> {
edits.add(edit); edits.add(edit);
const logId = `Edits.onEdit(timestamp=${edit.message.timestamp};target=${edit.targetSentTimestamp})`;
try { try {
// The conversation the edited message was in; we have to find it in the database // The conversation the edited message was in; we have to find it in the database
// to to figure that out. // to to figure that out.
@ -57,11 +59,7 @@ export async function onEdit(edit: EditAttributesType): Promise<void> {
); );
if (!targetConversation) { if (!targetConversation) {
log.info( log.info(`${logId}: No target conversation`);
'No target conversation for edit',
edit.fromId,
edit.targetSentTimestamp
);
return; return;
} }
@ -69,10 +67,7 @@ export async function onEdit(edit: EditAttributesType): Promise<void> {
// Do not await, since this can deadlock the queue // Do not await, since this can deadlock the queue
drop( drop(
targetConversation.queueJob('Edits.onEdit', async () => { targetConversation.queueJob('Edits.onEdit', async () => {
log.info('Handling edit for', { log.info(`${logId}: Handling edit`);
targetSentTimestamp: edit.targetSentTimestamp,
sentAt: edit.message.timestamp,
});
const messages = await window.Signal.Data.getMessagesBySentAt( const messages = await window.Signal.Data.getMessagesBySentAt(
edit.targetSentTimestamp edit.targetSentTimestamp
@ -86,11 +81,7 @@ export async function onEdit(edit: EditAttributesType): Promise<void> {
); );
if (!targetMessage) { if (!targetMessage) {
log.info( log.info(`${logId}: No message`);
'No message for edit',
edit.fromId,
edit.targetSentTimestamp
);
return; return;
} }
@ -106,6 +97,6 @@ export async function onEdit(edit: EditAttributesType): Promise<void> {
}) })
); );
} catch (error) { } catch (error) {
log.error('Edits.onEdit error:', Errors.toLogFormat(error)); log.error(`${logId} error:`, Errors.toLogFormat(error));
} }
} }

View file

@ -751,6 +751,7 @@ function copyOverMessageAttributesIntoEditHistory(
...messageAttributes, ...messageAttributes,
// Always take attachments from the edited message (they might be absent) // Always take attachments from the edited message (they might be absent)
attachments: undefined, attachments: undefined,
editMessageTimestamp: undefined,
quote: undefined, quote: undefined,
preview: [], preview: [],
...editedMessageAttributes, ...editedMessageAttributes,

View file

@ -42,6 +42,9 @@ export function SmartEditHistoryMessagesModal(): JSX.Element {
isEditedMessage: false, 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,
// Make sure that the timestamp is the correct timestamp from attributes
// not the one that the selector derives.
timestamp: messageAttributes.timestamp,
})); }));
}, [messagesAttributes, messagePropsSelector]); }, [messagesAttributes, messagePropsSelector]);