Store all story reactions as messages
This commit is contained in:
parent
f13611712c
commit
54aa0d39b9
12 changed files with 237 additions and 223 deletions
|
@ -445,7 +445,7 @@ export const getPropsForStoryReplyContext = createSelectorCreator(
|
|||
(
|
||||
message: Pick<
|
||||
MessageWithUIFieldsType,
|
||||
'body' | 'conversationId' | 'storyReactionEmoji' | 'storyReplyContext'
|
||||
'body' | 'conversationId' | 'storyReaction' | 'storyReplyContext'
|
||||
>,
|
||||
{
|
||||
conversationSelector,
|
||||
|
@ -455,7 +455,7 @@ export const getPropsForStoryReplyContext = createSelectorCreator(
|
|||
ourConversationId?: string;
|
||||
}
|
||||
): PropsData['storyReplyContext'] => {
|
||||
const { storyReactionEmoji, storyReplyContext } = message;
|
||||
const { storyReaction, storyReplyContext } = message;
|
||||
if (!storyReplyContext) {
|
||||
return undefined;
|
||||
}
|
||||
|
@ -474,7 +474,7 @@ export const getPropsForStoryReplyContext = createSelectorCreator(
|
|||
authorTitle,
|
||||
conversationColor,
|
||||
customColor,
|
||||
emoji: storyReactionEmoji,
|
||||
emoji: storyReaction?.emoji,
|
||||
isFromMe,
|
||||
rawAttachment: storyReplyContext.attachment
|
||||
? processQuoteAttachment(storyReplyContext.attachment)
|
||||
|
|
|
@ -6,7 +6,6 @@ import { pick } from 'lodash';
|
|||
|
||||
import type { GetConversationByIdType } from './conversations';
|
||||
import type { ConversationType } from '../ducks/conversations';
|
||||
import type { MessageReactionType } from '../../model-types.d';
|
||||
import type { AttachmentType } from '../../types/Attachment';
|
||||
import type {
|
||||
ConversationStoryType,
|
||||
|
@ -64,10 +63,6 @@ export const getAddStoryData = createSelector(
|
|||
({ addStoryData }): AddStoryData => addStoryData
|
||||
);
|
||||
|
||||
function getReactionUniqueId(reaction: MessageReactionType): string {
|
||||
return `${reaction.fromId}:${reaction.targetAuthorUuid}:${reaction.timestamp}`;
|
||||
}
|
||||
|
||||
function sortByRecencyAndUnread(
|
||||
storyA: ConversationStoryType,
|
||||
storyB: ConversationStoryType
|
||||
|
@ -273,34 +268,12 @@ export const getStoryReplies = createSelector(
|
|||
conversationSelector,
|
||||
contactNameColorSelector,
|
||||
me,
|
||||
{ stories, replyState }: Readonly<StoriesStateType>
|
||||
{ replyState }: Readonly<StoriesStateType>
|
||||
): ReplyStateType | undefined => {
|
||||
if (!replyState) {
|
||||
return;
|
||||
}
|
||||
|
||||
const foundStory = stories.find(
|
||||
story => story.messageId === replyState.messageId
|
||||
);
|
||||
|
||||
const reactions = foundStory
|
||||
? (foundStory.reactions || []).map(reaction => {
|
||||
const conversation = conversationSelector(reaction.fromId);
|
||||
|
||||
return {
|
||||
author: getAvatarData(conversation),
|
||||
contactNameColor: contactNameColorSelector(
|
||||
foundStory.conversationId,
|
||||
conversation.id
|
||||
),
|
||||
conversationId: reaction.fromId,
|
||||
id: getReactionUniqueId(reaction),
|
||||
reactionEmoji: reaction.emoji,
|
||||
timestamp: reaction.timestamp,
|
||||
};
|
||||
})
|
||||
: [];
|
||||
|
||||
const replies = replyState.replies.map(reply => {
|
||||
const conversation =
|
||||
reply.type === 'outgoing'
|
||||
|
@ -316,6 +289,7 @@ export const getStoryReplies = createSelector(
|
|||
'id',
|
||||
'timestamp',
|
||||
]),
|
||||
reactionEmoji: reply.storyReaction?.emoji,
|
||||
contactNameColor: contactNameColorSelector(
|
||||
reply.conversationId,
|
||||
conversation.id
|
||||
|
@ -325,13 +299,9 @@ export const getStoryReplies = createSelector(
|
|||
};
|
||||
});
|
||||
|
||||
const combined = [...replies, ...reactions].sort((a, b) =>
|
||||
a.timestamp > b.timestamp ? 1 : -1
|
||||
);
|
||||
|
||||
return {
|
||||
messageId: replyState.messageId,
|
||||
replies: combined,
|
||||
replies,
|
||||
};
|
||||
}
|
||||
);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue