2023-01-05 00:22:36 +00:00
|
|
|
// Copyright 2023 Signal Messenger, LLC
|
|
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
|
|
|
import { createSelector } from 'reselect';
|
|
|
|
|
|
|
|
import type { StateType } from '../reducer';
|
2024-11-20 16:38:45 +00:00
|
|
|
import type {
|
|
|
|
ComposerStateType,
|
|
|
|
QuotedMessageForComposerType,
|
|
|
|
} from '../ducks/composer';
|
2023-01-05 00:22:36 +00:00
|
|
|
import { getComposerStateForConversation } from '../ducks/composer';
|
|
|
|
|
|
|
|
export const getComposerState = (state: StateType): ComposerStateType =>
|
|
|
|
state.composer;
|
|
|
|
|
|
|
|
export const getComposerStateForConversationIdSelector = createSelector(
|
|
|
|
getComposerState,
|
|
|
|
composer => (conversationId: string) =>
|
|
|
|
getComposerStateForConversation(composer, conversationId)
|
|
|
|
);
|
|
|
|
|
|
|
|
export const getQuotedMessageSelector = createSelector(
|
|
|
|
getComposerStateForConversationIdSelector,
|
|
|
|
composerStateForConversationIdSelector =>
|
2024-11-20 16:38:45 +00:00
|
|
|
(conversationId: string): QuotedMessageForComposerType | undefined =>
|
2023-01-05 00:22:36 +00:00
|
|
|
composerStateForConversationIdSelector(conversationId).quotedMessage
|
|
|
|
);
|