Ensure ESC removes quoted reply when drafting
This commit is contained in:
parent
fd9e3ea7e0
commit
19f7bff8a3
5 changed files with 31 additions and 30 deletions
8
ts/model-types.d.ts
vendored
8
ts/model-types.d.ts
vendored
|
@ -38,6 +38,7 @@ import type { AnyPaymentEvent } from './types/Payment';
|
|||
import AccessRequiredEnum = Proto.AccessControl.AccessRequired;
|
||||
import MemberRoleEnum = Proto.Member.Role;
|
||||
import type { MessageRequestResponseEvent } from './types/MessageRequestResponseEvent';
|
||||
import type { QuotedMessageForComposerType } from './state/ducks/composer';
|
||||
|
||||
export type LastMessageStatus =
|
||||
| 'paused'
|
||||
|
@ -97,10 +98,11 @@ export type QuotedMessageType = {
|
|||
id: number | null;
|
||||
isGiftBadge?: boolean;
|
||||
isViewOnce: boolean;
|
||||
// `messageId` is deprecated
|
||||
messageId?: string;
|
||||
referencedMessageNotFound: boolean;
|
||||
text?: string;
|
||||
/** @deprecated `messageId` is used only in composer state, but still may exist in DB
|
||||
* records, particularly for messages sent from this device */
|
||||
messageId?: string;
|
||||
};
|
||||
|
||||
type StoryReplyContextType = {
|
||||
|
@ -324,7 +326,7 @@ export type DraftEditMessageType = {
|
|||
body: string;
|
||||
preview?: LinkPreviewType;
|
||||
targetMessageId: string;
|
||||
quote?: QuotedMessageType;
|
||||
quote?: QuotedMessageForComposerType['quote'];
|
||||
};
|
||||
|
||||
export type ConversationAttributesType = {
|
||||
|
|
|
@ -105,19 +105,17 @@ type ComposerStateByConversationType = {
|
|||
linkPreviewLoading: boolean;
|
||||
linkPreviewResult?: LinkPreviewType;
|
||||
messageCompositionId: string;
|
||||
quotedMessage?: Pick<
|
||||
ReadonlyMessageAttributesType,
|
||||
'conversationId' | 'quote'
|
||||
>;
|
||||
quotedMessage?: QuotedMessageForComposerType;
|
||||
sendCounter: number;
|
||||
shouldSendHighQualityAttachments?: boolean;
|
||||
};
|
||||
|
||||
// eslint-disable-next-line local-rules/type-alias-readonlydeep
|
||||
export type QuotedMessageType = Pick<
|
||||
ReadonlyMessageAttributesType,
|
||||
'conversationId' | 'quote'
|
||||
>;
|
||||
export type QuotedMessageForComposerType = ReadonlyDeep<{
|
||||
conversationId: ReadonlyMessageAttributesType['conversationId'];
|
||||
quote: ReadonlyMessageAttributesType['quote'] & {
|
||||
messageId?: string;
|
||||
};
|
||||
}>;
|
||||
|
||||
// eslint-disable-next-line local-rules/type-alias-readonlydeep
|
||||
export type ComposerStateType = {
|
||||
|
@ -212,7 +210,7 @@ export type SetQuotedMessageActionType = {
|
|||
type: typeof SET_QUOTED_MESSAGE;
|
||||
payload: {
|
||||
conversationId: string;
|
||||
quotedMessage?: QuotedMessageType;
|
||||
quotedMessage?: QuotedMessageForComposerType;
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -713,7 +711,7 @@ export function setQuoteByMessageId(
|
|||
return async (dispatch, getState) => {
|
||||
const conversation = window.ConversationController.get(conversationId);
|
||||
if (!conversation) {
|
||||
throw new Error('sendStickerMessage: No conversation found');
|
||||
throw new Error('setQuoteByMessageId: No conversation found');
|
||||
}
|
||||
|
||||
const draftEditMessage = conversation.get('draftEditMessage');
|
||||
|
@ -1373,7 +1371,7 @@ function setMediaQualitySetting(
|
|||
|
||||
function setQuotedMessage(
|
||||
conversationId: string,
|
||||
quotedMessage?: QuotedMessageType
|
||||
quotedMessage?: QuotedMessageForComposerType
|
||||
): SetQuotedMessageActionType {
|
||||
return {
|
||||
type: SET_QUOTED_MESSAGE,
|
||||
|
|
|
@ -4,7 +4,10 @@
|
|||
import { createSelector } from 'reselect';
|
||||
|
||||
import type { StateType } from '../reducer';
|
||||
import type { ComposerStateType, QuotedMessageType } from '../ducks/composer';
|
||||
import type {
|
||||
ComposerStateType,
|
||||
QuotedMessageForComposerType,
|
||||
} from '../ducks/composer';
|
||||
import { getComposerStateForConversation } from '../ducks/composer';
|
||||
|
||||
export const getComposerState = (state: StateType): ComposerStateType =>
|
||||
|
@ -19,6 +22,6 @@ export const getComposerStateForConversationIdSelector = createSelector(
|
|||
export const getQuotedMessageSelector = createSelector(
|
||||
getComposerStateForConversationIdSelector,
|
||||
composerStateForConversationIdSelector =>
|
||||
(conversationId: string): QuotedMessageType | undefined =>
|
||||
(conversationId: string): QuotedMessageForComposerType | undefined =>
|
||||
composerStateForConversationIdSelector(conversationId).quotedMessage
|
||||
);
|
||||
|
|
|
@ -466,7 +466,6 @@ describe('Message', () => {
|
|||
text: 'hey!',
|
||||
id: 34233,
|
||||
isViewOnce: false,
|
||||
messageId: 'message-id',
|
||||
referencedMessageNotFound: false,
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
} as any,
|
||||
|
@ -478,7 +477,6 @@ describe('Message', () => {
|
|||
attachments: [],
|
||||
id: 34233,
|
||||
isViewOnce: false,
|
||||
messageId: 'message-id',
|
||||
referencedMessageNotFound: false,
|
||||
},
|
||||
});
|
||||
|
@ -502,7 +500,6 @@ describe('Message', () => {
|
|||
attachments: [],
|
||||
id: 34233,
|
||||
isViewOnce: false,
|
||||
messageId: 'message-id',
|
||||
referencedMessageNotFound: false,
|
||||
},
|
||||
});
|
||||
|
@ -531,7 +528,6 @@ describe('Message', () => {
|
|||
],
|
||||
id: 34233,
|
||||
isViewOnce: false,
|
||||
messageId: 'message-id',
|
||||
referencedMessageNotFound: false,
|
||||
},
|
||||
});
|
||||
|
@ -564,7 +560,6 @@ describe('Message', () => {
|
|||
],
|
||||
id: 34233,
|
||||
isViewOnce: false,
|
||||
messageId: 'message-id',
|
||||
referencedMessageNotFound: false,
|
||||
},
|
||||
});
|
||||
|
@ -584,7 +579,6 @@ describe('Message', () => {
|
|||
],
|
||||
id: 34233,
|
||||
isViewOnce: false,
|
||||
messageId: 'message-id',
|
||||
referencedMessageNotFound: false,
|
||||
},
|
||||
});
|
||||
|
@ -619,7 +613,6 @@ describe('Message', () => {
|
|||
],
|
||||
id: 34233,
|
||||
isViewOnce: false,
|
||||
messageId: 'message-id',
|
||||
referencedMessageNotFound: false,
|
||||
},
|
||||
});
|
||||
|
@ -639,7 +632,6 @@ describe('Message', () => {
|
|||
],
|
||||
id: 34233,
|
||||
isViewOnce: false,
|
||||
messageId: 'message-id',
|
||||
referencedMessageNotFound: false,
|
||||
},
|
||||
});
|
||||
|
@ -732,7 +724,6 @@ describe('Message', () => {
|
|||
],
|
||||
id: 34233,
|
||||
isViewOnce: false,
|
||||
messageId: 'message-id',
|
||||
referencedMessageNotFound: false,
|
||||
},
|
||||
preview: [
|
||||
|
@ -774,7 +765,6 @@ describe('Message', () => {
|
|||
],
|
||||
id: 34233,
|
||||
isViewOnce: false,
|
||||
messageId: 'message-id',
|
||||
referencedMessageNotFound: false,
|
||||
},
|
||||
preview: [
|
||||
|
|
|
@ -5,7 +5,6 @@ import type { AttachmentType } from '../types/Attachment';
|
|||
import type {
|
||||
MessageAttributesType,
|
||||
QuotedAttachmentType,
|
||||
QuotedMessageType,
|
||||
} from '../model-types.d';
|
||||
import type { LinkPreviewType } from '../types/message/LinkPreviews';
|
||||
import type { StickerType } from '../types/Stickers';
|
||||
|
@ -19,15 +18,23 @@ import { map, take, collect } from './iterables';
|
|||
import { strictAssert } from './assert';
|
||||
import { getMessageSentTimestamp } from './getMessageSentTimestamp';
|
||||
import { getLocalAttachmentUrl } from './getLocalAttachmentUrl';
|
||||
import type { QuotedMessageForComposerType } from '../state/ducks/composer';
|
||||
|
||||
export async function makeQuote(
|
||||
quotedMessage: MessageAttributesType
|
||||
): Promise<QuotedMessageType> {
|
||||
): Promise<QuotedMessageForComposerType['quote']> {
|
||||
const contact = getAuthor(quotedMessage);
|
||||
|
||||
strictAssert(contact, 'makeQuote: no contact');
|
||||
|
||||
const { attachments, bodyRanges, payment, preview, sticker } = quotedMessage;
|
||||
const {
|
||||
attachments,
|
||||
bodyRanges,
|
||||
id: messageId,
|
||||
payment,
|
||||
preview,
|
||||
sticker,
|
||||
} = quotedMessage;
|
||||
|
||||
const quoteId = getMessageSentTimestamp(quotedMessage, { log });
|
||||
|
||||
|
@ -41,6 +48,7 @@ export async function makeQuote(
|
|||
id: quoteId,
|
||||
isViewOnce: isTapToView(quotedMessage),
|
||||
isGiftBadge: isGiftBadge(quotedMessage),
|
||||
messageId,
|
||||
referencedMessageNotFound: false,
|
||||
text: getQuoteBodyText(quotedMessage, quoteId),
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue