signal-desktop/ts/state/smart/StoryCreator.tsx

45 lines
1.6 KiB
TypeScript
Raw Normal View History

2022-06-17 00:48:57 +00:00
// Copyright 2022 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
import React from 'react';
import { useSelector } from 'react-redux';
import type { LocalizerType } from '../../types/Util';
import type { StateType } from '../reducer';
import { LinkPreviewSourceType } from '../../types/LinkPreview';
import { StoryCreator } from '../../components/StoryCreator';
2022-08-02 19:31:55 +00:00
import { getDistributionLists } from '../selectors/storyDistributionLists';
2022-06-17 00:48:57 +00:00
import { getIntl } from '../selectors/user';
import { getLinkPreview } from '../selectors/linkPreviews';
2022-08-02 19:31:55 +00:00
import { getAllSignalConnections, getMe } from '../selectors/conversations';
2022-06-17 00:48:57 +00:00
import { useLinkPreviewActions } from '../ducks/linkPreviews';
2022-08-02 19:31:55 +00:00
import { useStoriesActions } from '../ducks/stories';
2022-06-17 00:48:57 +00:00
export type PropsType = {
onClose: () => unknown;
};
export function SmartStoryCreator({ onClose }: PropsType): JSX.Element | null {
const { debouncedMaybeGrabLinkPreview } = useLinkPreviewActions();
2022-08-02 19:31:55 +00:00
const { sendStoryMessage } = useStoriesActions();
2022-06-17 00:48:57 +00:00
const i18n = useSelector<StateType, LocalizerType>(getIntl);
const linkPreviewForSource = useSelector(getLinkPreview);
2022-08-02 19:31:55 +00:00
const distributionLists = useSelector(getDistributionLists);
const me = useSelector(getMe);
const signalConnections = useSelector(getAllSignalConnections);
2022-06-17 00:48:57 +00:00
return (
<StoryCreator
debouncedMaybeGrabLinkPreview={debouncedMaybeGrabLinkPreview}
2022-08-02 19:31:55 +00:00
distributionLists={distributionLists}
2022-06-17 00:48:57 +00:00
i18n={i18n}
linkPreview={linkPreviewForSource(LinkPreviewSourceType.StoryCreator)}
2022-08-02 19:31:55 +00:00
me={me}
2022-06-17 00:48:57 +00:00
onClose={onClose}
2022-08-02 19:31:55 +00:00
onSend={sendStoryMessage}
signalConnections={signalConnections}
2022-06-17 00:48:57 +00:00
/>
);
}