mirror of
https://github.com/oxen-io/session-desktop.git
synced 2023-12-14 02:12:57 +01:00
29 lines
1 KiB
TypeScript
29 lines
1 KiB
TypeScript
import { createSelector } from 'reselect';
|
|
import { StagedAttachmentType } from '../../components/session/conversation/composition/CompositionBox';
|
|
import { StagedAttachmentsStateType } from '../ducks/stagedAttachments';
|
|
import { StateType } from '../reducer';
|
|
import { getSelectedConversationKey } from './conversations';
|
|
|
|
export const getStagedAttachmentsState = (state: StateType): StagedAttachmentsStateType =>
|
|
state.stagedAttachments;
|
|
|
|
const getStagedAttachmentsForConversation = (
|
|
state: StagedAttachmentsStateType,
|
|
conversationKey: string | undefined
|
|
) => {
|
|
if (!conversationKey) {
|
|
return undefined;
|
|
}
|
|
return state.stagedAttachments[conversationKey] || [];
|
|
};
|
|
|
|
export const getStagedAttachmentsForCurrentConversation = createSelector(
|
|
[getSelectedConversationKey, getStagedAttachmentsState],
|
|
(
|
|
selectedConversationKey: string | undefined,
|
|
state: StagedAttachmentsStateType
|
|
): Array<StagedAttachmentType> | undefined => {
|
|
return getStagedAttachmentsForConversation(state, selectedConversationKey);
|
|
}
|
|
);
|