signal-desktop/ts/state/smart/ShortcutGuideModal.tsx
Jamie Kyle 27b55e472d
Refactor smart components
Co-authored-by: Fedor Indutny <79877362+indutny-signal@users.noreply.github.com>
2024-03-13 13:44:13 -07:00

46 lines
1.5 KiB
TypeScript

// Copyright 2019 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
import React, { memo, useMemo } from 'react';
import { useSelector } from 'react-redux';
import { ShortcutGuideModal } from '../../components/ShortcutGuideModal';
import { countStickers } from '../../components/stickers/lib';
import { getIntl, getPlatform } from '../selectors/user';
import {
getBlessedStickerPacks,
getInstalledStickerPacks,
getKnownStickerPacks,
getReceivedStickerPacks,
} from '../selectors/stickers';
import { useGlobalModalActions } from '../ducks/globalModals';
export const SmartShortcutGuideModal = memo(function SmartShortcutGuideModal() {
const i18n = useSelector(getIntl);
const blessedPacks = useSelector(getBlessedStickerPacks);
const installedPacks = useSelector(getInstalledStickerPacks);
const knownPacks = useSelector(getKnownStickerPacks);
const receivedPacks = useSelector(getReceivedStickerPacks);
const platform = useSelector(getPlatform);
const { closeShortcutGuideModal } = useGlobalModalActions();
const hasInstalledStickers = useMemo(() => {
return (
countStickers({
knownPacks,
blessedPacks,
installedPacks,
receivedPacks,
}) > 0
);
}, [blessedPacks, installedPacks, knownPacks, receivedPacks]);
return (
<ShortcutGuideModal
hasInstalledStickers={hasInstalledStickers}
platform={platform}
closeShortcutGuideModal={closeShortcutGuideModal}
i18n={i18n}
/>
);
});