import React, { memo, useCallback, useMemo, useRef, } from '../../../lib/teact/teact'; import { getActions, withGlobal } from '../../../global'; import type { FC } from '../../../lib/teact/teact'; import type { ApiSticker, ApiStickerSet } from '../../../api/types'; import renderText from '../../common/helpers/renderText'; import { pick } from '../../../util/iteratees'; import useHistoryBack from '../../../hooks/useHistoryBack'; import { useIntersectionObserver } from '../../../hooks/useIntersectionObserver'; import useLang from '../../../hooks/useLang'; import StickerSetCard from '../../common/StickerSetCard'; type OwnProps = { isActive?: boolean; onReset: () => void; }; type StateProps = { customEmojiSetIds?: string[]; stickerSetsById: Record; }; const SettingsCustomEmoji: FC = ({ isActive, customEmojiSetIds, stickerSetsById, onReset, }) => { const { openStickerSet } = getActions(); const lang = useLang(); // eslint-disable-next-line no-null/no-null const stickerSettingsRef = useRef(null); const { observe: observeIntersectionForCovers } = useIntersectionObserver({ rootRef: stickerSettingsRef }); useHistoryBack({ isActive, onBack: onReset, }); const handleStickerSetClick = useCallback((sticker: ApiSticker) => { openStickerSet({ stickerSetInfo: sticker.stickerSetInfo, }); }, [openStickerSet]); const customEmojiSets = useMemo(() => ( customEmojiSetIds && Object.values(pick(stickerSetsById, customEmojiSetIds)) ), [customEmojiSetIds, stickerSetsById]); return (
{customEmojiSets && (
{customEmojiSets.map((stickerSet: ApiStickerSet) => ( ))}

{renderText(lang('EmojiBotInfo'), ['links'])}

)}
); }; export default memo(withGlobal( (global) => { return { customEmojiSetIds: global.customEmojis.added.setIds, stickerSetsById: global.stickers.setsById, }; }, )(SettingsCustomEmoji));