Always fetch link preview on edit message
This commit is contained in:
parent
b13cc693c7
commit
8aa397b7a6
1 changed files with 2 additions and 28 deletions
|
@ -20,16 +20,12 @@ import type { BoundActionCreatorsMapObject } from '../../hooks/useBoundActions';
|
||||||
import type { DraftBodyRanges } from '../../types/BodyRange';
|
import type { DraftBodyRanges } from '../../types/BodyRange';
|
||||||
import { BodyRange } from '../../types/BodyRange';
|
import { BodyRange } from '../../types/BodyRange';
|
||||||
import type { LinkPreviewType } from '../../types/message/LinkPreviews';
|
import type { LinkPreviewType } from '../../types/message/LinkPreviews';
|
||||||
import type {
|
import type { MessageAttributesType } from '../../model-types.d';
|
||||||
DraftEditMessageType,
|
|
||||||
MessageAttributesType,
|
|
||||||
} from '../../model-types.d';
|
|
||||||
import type { NoopActionType } from './noop';
|
import type { NoopActionType } from './noop';
|
||||||
import type { ShowToastActionType } from './toast';
|
import type { ShowToastActionType } from './toast';
|
||||||
import type { StateType as RootStateType } from '../reducer';
|
import type { StateType as RootStateType } from '../reducer';
|
||||||
import * as log from '../../logging/log';
|
import * as log from '../../logging/log';
|
||||||
import * as Errors from '../../types/errors';
|
import * as Errors from '../../types/errors';
|
||||||
import * as LinkPreview from '../../types/LinkPreview';
|
|
||||||
import {
|
import {
|
||||||
ADD_PREVIEW as ADD_LINK_PREVIEW,
|
ADD_PREVIEW as ADD_LINK_PREVIEW,
|
||||||
REMOVE_PREVIEW as REMOVE_LINK_PREVIEW,
|
REMOVE_PREVIEW as REMOVE_LINK_PREVIEW,
|
||||||
|
@ -255,24 +251,6 @@ export const actions = {
|
||||||
setQuotedMessage,
|
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 {
|
function incrementSendCounter(conversationId: string): IncrementSendActionType {
|
||||||
return {
|
return {
|
||||||
type: INCREMENT_SEND_COUNTER,
|
type: INCREMENT_SEND_COUNTER,
|
||||||
|
@ -1014,11 +992,7 @@ function onEditorStateChange({
|
||||||
hasDraftAttachments(conversation.attributes.draftAttachments, {
|
hasDraftAttachments(conversation.attributes.draftAttachments, {
|
||||||
includePending: true,
|
includePending: true,
|
||||||
}) ||
|
}) ||
|
||||||
Boolean(conversation.attributes.draftEditMessage?.attachmentThumbnail) ||
|
Boolean(conversation.attributes.draftEditMessage?.attachmentThumbnail)
|
||||||
hadSameLinkPreviewDismissed(
|
|
||||||
messageText,
|
|
||||||
conversation.attributes.draftEditMessage
|
|
||||||
)
|
|
||||||
) {
|
) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue