// Copyright 2022 Signal Messenger, LLC // SPDX-License-Identifier: AGPL-3.0-only import React from 'react'; import { useSelector } from 'react-redux'; import type { GetConversationByIdType } from '../selectors/conversations'; import type { LocalizerType } from '../../types/Util'; import type { MediaItemType } from '../../types/MediaItem'; import type { StateType } from '../reducer'; import { Lightbox } from '../../components/Lightbox'; import { getConversationSelector } from '../selectors/conversations'; import { getIntl } from '../selectors/user'; import { useGlobalModalActions } from '../ducks/globalModals'; import { useLightboxActions } from '../ducks/lightbox'; import { getIsViewOnce, getMedia, getSelectedIndex, shouldShowLightbox, } from '../selectors/lightbox'; export function SmartLightbox(): JSX.Element | null { const i18n = useSelector(getIntl); const { closeLightbox } = useLightboxActions(); const { toggleForwardMessageModal } = useGlobalModalActions(); const conversationSelector = useSelector( getConversationSelector ); const isShowingLightbox = useSelector(shouldShowLightbox); const isViewOnce = useSelector(getIsViewOnce); const media = useSelector>(getMedia); const selectedIndex = useSelector(getSelectedIndex); if (!isShowingLightbox) { return null; } return ( ); }