Always fetch link preview on edit message

This commit is contained in:
Josh Perez 2023-08-28 13:53:35 -04:00 committed by GitHub
parent b13cc693c7
commit 8aa397b7a6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -20,16 +20,12 @@ import type { BoundActionCreatorsMapObject } from '../../hooks/useBoundActions';
import type { DraftBodyRanges } from '../../types/BodyRange';
import { BodyRange } from '../../types/BodyRange';
import type { LinkPreviewType } from '../../types/message/LinkPreviews';
import type {
DraftEditMessageType,
MessageAttributesType,
} from '../../model-types.d';
import type { MessageAttributesType } from '../../model-types.d';
import type { NoopActionType } from './noop';
import type { ShowToastActionType } from './toast';
import type { StateType as RootStateType } from '../reducer';
import * as log from '../../logging/log';
import * as Errors from '../../types/errors';
import * as LinkPreview from '../../types/LinkPreview';
import {
ADD_PREVIEW as ADD_LINK_PREVIEW,
REMOVE_PREVIEW as REMOVE_LINK_PREVIEW,
@ -255,24 +251,6 @@ export const actions = {
setQuotedMessage,
};
function hadSameLinkPreviewDismissed(
messageText: string,
draftEditMessage: DraftEditMessageType | undefined
): boolean {
if (!draftEditMessage) {
return false;
}
const currentLink = LinkPreview.findLinks(messageText).find(
LinkPreview.shouldPreviewHref
);
const prevLink = LinkPreview.findLinks(draftEditMessage.body).find(
LinkPreview.shouldPreviewHref
);
return currentLink === prevLink && !draftEditMessage.preview;
}
function incrementSendCounter(conversationId: string): IncrementSendActionType {
return {
type: INCREMENT_SEND_COUNTER,
@ -1014,11 +992,7 @@ function onEditorStateChange({
hasDraftAttachments(conversation.attributes.draftAttachments, {
includePending: true,
}) ||
Boolean(conversation.attributes.draftEditMessage?.attachmentThumbnail) ||
hadSameLinkPreviewDismissed(
messageText,
conversation.attributes.draftEditMessage
)
Boolean(conversation.attributes.draftEditMessage?.attachmentThumbnail)
) {
return;
}