Hydrate body ranges for story replies
This commit is contained in:
parent
9f85db3fd8
commit
be6e988a95
39 changed files with 221 additions and 172 deletions
|
@ -37,7 +37,7 @@ import type { UUIDStringType } from '../../types/UUID';
|
|||
|
||||
import type { EmbeddedContactType } from '../../types/EmbeddedContact';
|
||||
import { embeddedContactSelector } from '../../types/EmbeddedContact';
|
||||
import type { AssertProps, BodyRangesType } from '../../types/Util';
|
||||
import type { AssertProps, HydratedBodyRangesType } from '../../types/Util';
|
||||
import type { LinkPreviewType } from '../../types/message/LinkPreviews';
|
||||
import { getMentionsRegex } from '../../types/Message';
|
||||
import { CallMode } from '../../types/Calling';
|
||||
|
@ -289,7 +289,7 @@ export const processBodyRanges = createSelectorCreator(memoizeByRoot, isEqual)(
|
|||
(
|
||||
{ bodyRanges }: Pick<MessageWithUIFieldsType, 'bodyRanges'>,
|
||||
{ conversationSelector }: { conversationSelector: GetConversationByIdType }
|
||||
): BodyRangesType | undefined => {
|
||||
): HydratedBodyRangesType | undefined => {
|
||||
if (!bodyRanges) {
|
||||
return undefined;
|
||||
}
|
||||
|
@ -307,7 +307,7 @@ export const processBodyRanges = createSelectorCreator(memoizeByRoot, isEqual)(
|
|||
})
|
||||
.sort((a, b) => b.start - a.start);
|
||||
},
|
||||
(_, ranges): undefined | BodyRangesType => ranges
|
||||
(_, ranges): undefined | HydratedBodyRangesType => ranges
|
||||
);
|
||||
|
||||
const getAuthorForMessage = createSelectorCreator(memoizeByRoot)(
|
||||
|
@ -780,7 +780,7 @@ export const getPropsForMessage: (
|
|||
(
|
||||
_,
|
||||
attachments: Array<AttachmentType>,
|
||||
bodyRanges: BodyRangesType | undefined,
|
||||
bodyRanges: HydratedBodyRangesType | undefined,
|
||||
author: PropsData['author'],
|
||||
previews: Array<LinkPreviewType>,
|
||||
reactions: PropsData['reactions'],
|
||||
|
|
|
@ -28,7 +28,7 @@ import {
|
|||
getConversationSelector,
|
||||
} from './conversations';
|
||||
|
||||
import type { BodyRangeType } from '../../types/Util';
|
||||
import type { BodyRangeType, HydratedBodyRangeType } from '../../types/Util';
|
||||
import * as log from '../../logging/log';
|
||||
import { getOwn } from '../../util/getOwn';
|
||||
|
||||
|
@ -173,14 +173,17 @@ export const getCachedSelectorForMessageSearchResult = createSelector(
|
|||
conversationId: message.conversationId,
|
||||
sentAt: message.sent_at,
|
||||
snippet: message.snippet || '',
|
||||
bodyRanges: bodyRanges.map((bodyRange: BodyRangeType) => {
|
||||
const conversation = conversationSelector(bodyRange.mentionUuid);
|
||||
bodyRanges: bodyRanges.map(
|
||||
(bodyRange: BodyRangeType): HydratedBodyRangeType => {
|
||||
const conversation = conversationSelector(bodyRange.mentionUuid);
|
||||
|
||||
return {
|
||||
...bodyRange,
|
||||
replacementText: conversation.title,
|
||||
};
|
||||
}),
|
||||
return {
|
||||
...bodyRange,
|
||||
conversationID: conversation.id,
|
||||
replacementText: conversation.title,
|
||||
};
|
||||
}
|
||||
),
|
||||
body: message.body || '',
|
||||
|
||||
isSelected: Boolean(
|
||||
|
|
|
@ -296,15 +296,20 @@ export const getStoryReplies = createSelector(
|
|||
? me
|
||||
: conversationSelector(reply.sourceUuid || reply.source);
|
||||
|
||||
const { bodyRanges } = reply;
|
||||
|
||||
return {
|
||||
author: getAvatarData(conversation),
|
||||
...pick(reply, [
|
||||
'body',
|
||||
'bodyRanges',
|
||||
'deletedForEveryone',
|
||||
'id',
|
||||
'timestamp',
|
||||
]),
|
||||
...pick(reply, ['body', 'deletedForEveryone', 'id', 'timestamp']),
|
||||
bodyRanges: bodyRanges?.map(bodyRange => {
|
||||
const mentionConvo = conversationSelector(bodyRange.mentionUuid);
|
||||
|
||||
return {
|
||||
...bodyRange,
|
||||
conversationID: mentionConvo.id,
|
||||
replacementText: mentionConvo.title,
|
||||
};
|
||||
}),
|
||||
reactionEmoji: reply.storyReaction?.emoji,
|
||||
contactNameColor: contactNameColorSelector(
|
||||
reply.conversationId,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue