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

51 lines
1.3 KiB
TypeScript
Raw Normal View History

// Copyright 2019-2022 Signal Messenger, LLC
2020-10-30 20:34:04 +00:00
// SPDX-License-Identifier: AGPL-3.0-only
2019-11-07 21:36:16 +00:00
import { connect } from 'react-redux';
import { mapDispatchToProps } from '../actions';
import { ShortcutGuideModal } from '../../components/ShortcutGuideModal';
import type { StateType } from '../reducer';
2019-11-07 21:36:16 +00:00
import { countStickers } from '../../components/stickers/lib';
import { getIntl, getPlatform } from '../selectors/user';
import {
getBlessedStickerPacks,
getInstalledStickerPacks,
getKnownStickerPacks,
getReceivedStickerPacks,
} from '../selectors/stickers';
export type ExternalProps = {
2019-11-07 21:36:16 +00:00
close: () => unknown;
};
const mapStateToProps = (state: StateType, props: ExternalProps) => {
const { close } = props;
const blessedPacks = getBlessedStickerPacks(state);
const installedPacks = getInstalledStickerPacks(state);
const knownPacks = getKnownStickerPacks(state);
const receivedPacks = getReceivedStickerPacks(state);
const hasInstalledStickers =
countStickers({
knownPacks,
blessedPacks,
installedPacks,
receivedPacks,
}) > 0;
2019-11-07 21:36:16 +00:00
const platform = getPlatform(state);
return {
close,
hasInstalledStickers,
platform,
i18n: getIntl(state),
};
};
const smart = connect(mapStateToProps, mapDispatchToProps);
export const SmartShortcutGuideModal = smart(ShortcutGuideModal);