// @flow import React from 'react'; import { withRouter } from 'react-router'; import * as MODALS from 'constants/modal_types'; import ModalError from 'modal/modalError'; import ModalDownloading from 'modal/modalDownloading'; import ModalAutoGenerateThumbnail from 'modal/modalAutoGenerateThumbnail'; import ModalAutoUpdateDownloaded from 'modal/modalAutoUpdateDownloaded'; import ModalUpgrade from 'modal/modalUpgrade'; import ModalFirstReward from 'modal/modalFirstReward'; import ModalRemoveFile from 'modal/modalRemoveFile'; import ModalTransactionFailed from 'modal/modalTransactionFailed'; import ModalFileTimeout from 'modal/modalFileTimeout'; import ModalAffirmPurchase from 'modal/modalAffirmPurchase'; import ModalRevokeClaim from 'modal/modalRevokeClaim'; import ModalPhoneCollection from 'modal/modalPhoneCollection'; import ModalFirstSubscription from 'modal/modalFirstSubscription'; import ModalConfirmTransaction from 'modal/modalConfirmTransaction'; import ModalRemoveBlocked from 'modal/modalRemoveBlocked'; import ModalSocialShare from 'modal/modalSocialShare'; import ModalSendTip from 'modal/modalSendTip'; import ModalPublish from 'modal/modalPublish'; import ModalPublishPreview from 'modal/modalPublishPreview'; import ModalOpenExternalResource from 'modal/modalOpenExternalResource'; import ModalConfirmThumbnailUpload from 'modal/modalConfirmThumbnailUpload'; import ModalWalletEncrypt from 'modal/modalWalletEncrypt'; import ModalWalletDecrypt from 'modal/modalWalletDecrypt'; import ModalWalletUnlock from 'modal/modalWalletUnlock'; import ModalRewardCode from 'modal/modalRewardCode'; import ModalPasswordUnsave from 'modal/modalPasswordUnsave'; import ModalCommentAcknowledgement from 'modal/modalCommentAcknowledgement'; import ModalWalletSend from 'modal/modalWalletSend'; import ModalWalletReceive from 'modal/modalWalletReceive'; import ModalYoutubeWelcome from 'modal/modalYoutubeWelcome'; import ModalCreateChannel from 'modal/modalChannelCreate'; import ModalSetReferrer from 'modal/modalSetReferrer'; import ModalSignOut from 'modal/modalSignOut'; import ModalSupportsLiquidate from 'modal/modalSupportsLiquidate'; import ModalConfirmAge from 'modal/modalConfirmAge'; import ModalFileSelection from 'modal/modalFileSelection'; import ModalSyncEnable from 'modal/modalSyncEnable'; import ModalImageUpload from 'modal/modalImageUpload'; import ModalMobileSearch from 'modal/modalMobileSearch'; import ModalViewImage from 'modal/modalViewImage'; import ModalMassTipsUnlock from 'modal/modalMassTipUnlock'; type Props = { modal: { id: string, modalProps: {} }, error: { message: string }, location: { pathname: string }, hideModal: () => void, }; function ModalRouter(props: Props) { const { modal, error, location, hideModal } = props; const { pathname } = location; // return ; React.useEffect(() => { hideModal(); }, [pathname, hideModal]); if (error) { return ; } if (!modal) { return null; } const { id, modalProps } = modal; switch (id) { case MODALS.UPGRADE: return ; case MODALS.DOWNLOADING: return ; case MODALS.AUTO_GENERATE_THUMBNAIL: return ; case MODALS.AUTO_UPDATE_DOWNLOADED: return ; case MODALS.ERROR: return ; case MODALS.FILE_TIMEOUT: return ; case MODALS.FIRST_REWARD: return ; case MODALS.TRANSACTION_FAILED: return ; case MODALS.CONFIRM_FILE_REMOVE: return ; case MODALS.AFFIRM_PURCHASE: return ; case MODALS.CONFIRM_CLAIM_REVOKE: return ; case MODALS.PHONE_COLLECTION: return ; case MODALS.FIRST_SUBSCRIPTION: return ; case MODALS.SEND_TIP: return ; case MODALS.SOCIAL_SHARE: return ; case MODALS.PUBLISH: return ; case MODALS.PUBLISH_PREVIEW: return ; case MODALS.CONFIRM_EXTERNAL_RESOURCE: return ; case MODALS.CONFIRM_TRANSACTION: return ; case MODALS.CONFIRM_THUMBNAIL_UPLOAD: return ; case MODALS.WALLET_ENCRYPT: return ; case MODALS.WALLET_DECRYPT: return ; case MODALS.WALLET_UNLOCK: return ; case MODALS.WALLET_PASSWORD_UNSAVE: return ; case MODALS.REWARD_GENERATED_CODE: return ; case MODALS.COMMENT_ACKNOWEDGEMENT: return ; case MODALS.WALLET_SEND: return ; case MODALS.WALLET_RECEIVE: return ; case MODALS.YOUTUBE_WELCOME: return ; case MODALS.CREATE_CHANNEL: return ; case MODALS.SET_REFERRER: return ; case MODALS.SIGN_OUT: return ; case MODALS.CONFIRM_AGE: return ; case MODALS.FILE_SELECTION: return ; case MODALS.LIQUIDATE_SUPPORTS: return ; case MODALS.REMOVE_BLOCKED: return ; case MODALS.IMAGE_UPLOAD: return ; case MODALS.SYNC_ENABLE: return ; case MODALS.MOBILE_SEARCH: return ; case MODALS.VIEW_IMAGE: return ; case MODALS.MASS_TIP_UNLOCK: return ; default: return null; } } export default withRouter(ModalRouter);