mirror of
https://github.com/oxen-io/session-desktop.git
synced 2023-12-14 02:12:57 +01:00
feat: getConversationQuotes selector for memoising quotes lookup state
This commit is contained in:
parent
e90e548715
commit
aa3855e49f
1 changed files with 17 additions and 4 deletions
|
@ -9,6 +9,7 @@ import {
|
|||
MessageModelPropsWithoutConvoProps,
|
||||
MessagePropsDetails,
|
||||
PropsForQuote,
|
||||
QuoteLookupType,
|
||||
ReduxConversationType,
|
||||
SortedMessageModelProps,
|
||||
} from '../ducks/conversations';
|
||||
|
@ -56,6 +57,13 @@ export const getConversationsCount = createSelector(getConversationLookup, (stat
|
|||
return Object.values(state).length;
|
||||
});
|
||||
|
||||
export const getConversationQuotes = createSelector(
|
||||
getConversations,
|
||||
(state: ConversationsStateType): QuoteLookupType | undefined => {
|
||||
return state.quotes;
|
||||
}
|
||||
);
|
||||
|
||||
export const getSelectedConversationKey = createSelector(
|
||||
getConversations,
|
||||
(state: ConversationsStateType): string | undefined => {
|
||||
|
@ -973,10 +981,10 @@ export const getMessageLinkPreviewProps = createSelector(getMessagePropsByMessag
|
|||
});
|
||||
|
||||
export const getMessageQuoteProps = createSelector(
|
||||
getConversations,
|
||||
getConversationQuotes,
|
||||
getMessagePropsByMessageId,
|
||||
(convosProps, msgProps) => {
|
||||
if (!convosProps || isEmpty(convosProps) || !msgProps || isEmpty(msgProps)) {
|
||||
(quotesProps, msgProps) => {
|
||||
if (!msgProps || isEmpty(msgProps)) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
|
@ -990,7 +998,12 @@ export const getMessageQuoteProps = createSelector(
|
|||
return undefined;
|
||||
}
|
||||
|
||||
const sourceMessage = convosProps.quotes[`${messageId}-${sender}`];
|
||||
// NOTE: if the message is not found, we still want to render the quote
|
||||
if (!quotesProps || isEmpty(quotesProps)) {
|
||||
return { direction, quote: { sender, referencedMessageNotFound: true } };
|
||||
}
|
||||
|
||||
const sourceMessage = quotesProps[`${messageId}-${sender}`];
|
||||
if (!sourceMessage) {
|
||||
return { direction, quote: { sender, referencedMessageNotFound: true } };
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue