Do not fetch link preview when edited message does not contain preview

This commit is contained in:
Josh Perez 2023-06-13 12:16:20 -07:00 committed by GitHub
parent 7c8dec4b21
commit bd7545e6d2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 7 deletions

View file

@ -665,22 +665,25 @@ export function CompositionArea({
emojiButtonRef.current?.close();
}, [emojiButtonRef]);
const clearQuote = useCallback(() => {
if (quotedMessageId) {
setQuoteByMessageId(conversationId, undefined);
}
if (draftEditMessage) {
const handleEscape = useCallback(() => {
if (linkPreviewResult) {
onCloseLinkPreview(conversationId);
} else if (draftEditMessage) {
discardEditMessage(conversationId);
} else if (quotedMessageId) {
setQuoteByMessageId(conversationId, undefined);
}
}, [
conversationId,
discardEditMessage,
draftEditMessage,
linkPreviewResult,
onCloseLinkPreview,
quotedMessageId,
setQuoteByMessageId,
]);
useEscapeHandling(clearQuote);
useEscapeHandling(handleEscape);
if (isSignalConversation) {
// TODO DESKTOP-4547

View file

@ -963,7 +963,10 @@ function onEditorStateChange({
hasDraftAttachments(conversation.attributes.draftAttachments, {
includePending: true,
}) ||
Boolean(conversation.attributes.draftEditMessage?.attachmentThumbnail)
Boolean(conversation.attributes.draftEditMessage?.attachmentThumbnail) ||
// If we already didn't have a preview attached, don't fetch another one
(conversation.attributes.draftEditMessage &&
!conversation.attributes.draftEditMessage.preview)
) {
return;
}