// @flow import * as ICONS from 'constants/icons'; import React from 'react'; import Button from 'component/button'; import classnames from 'classnames'; import Icon from 'component/common/icon'; import LbcMessage from 'component/common/lbc-message'; type Props = { removeSnack: (any) => void, snack: ?ToastParams, }; class SnackBar extends React.PureComponent { constructor(props: Props) { super(props); this.hideTimeout = null; } hideTimeout: ?TimeoutID; render() { const { snack, removeSnack } = this.props; if (!snack) { this.hideTimeout = null; // should be unmounting anyway, but be safe? return null; } const { message, subMessage, duration, linkText, linkTarget, isError } = snack; if (this.hideTimeout === null) { this.hideTimeout = setTimeout( () => { this.hideTimeout = null; removeSnack(); }, duration === 'long' ? 15000 : 5000 ); } return (

{message} {subMessage && (

{subMessage}

)}

{linkText && linkTarget && ( // This is a little weird because of `linkTarget` code in `lbry-redux` // Any navigation code should happen in the app, and that should be removed from lbry-redux
); } } export default SnackBar;