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';
|
|
|
|
import type { ComposerStateType, QuotedMessageType } from '../ducks/composer';
|
|
|
|
import { getComposerStateForConversation } from '../ducks/composer';
|
2023-04-18 01:16:41 +00:00
|
|
|
import { getRemoteConfig, isRemoteConfigFlagEnabled } from './items';
|
2023-01-05 00:22:36 +00:00
|
|
|
|
|
|
|
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 =>
|
|
|
|
(conversationId: string): QuotedMessageType | undefined =>
|
|
|
|
composerStateForConversationIdSelector(conversationId).quotedMessage
|
|
|
|
);
|
2023-04-14 18:16:28 +00:00
|
|
|
|
2023-04-18 01:16:41 +00:00
|
|
|
export const getIsFormattingFlagEnabled = createSelector(
|
2023-04-14 18:16:28 +00:00
|
|
|
getRemoteConfig,
|
2023-04-18 01:16:41 +00:00
|
|
|
remoteConfig => {
|
|
|
|
return isRemoteConfigFlagEnabled(remoteConfig, 'desktop.textFormatting');
|
2023-04-14 18:16:28 +00:00
|
|
|
}
|
|
|
|
);
|
|
|
|
|
2023-04-18 01:16:41 +00:00
|
|
|
export const getIsFormattingSpoilersFlagEnabled = createSelector(
|
2023-04-14 18:16:28 +00:00
|
|
|
getRemoteConfig,
|
2023-04-18 01:16:41 +00:00
|
|
|
remoteConfig => {
|
|
|
|
return isRemoteConfigFlagEnabled(
|
|
|
|
remoteConfig,
|
|
|
|
'desktop.textFormatting.spoilerSend'
|
2023-04-14 18:16:28 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
);
|