import React from 'react'; import PTRComponent from 'react-simple-pull-to-refresh'; import { Spinner } from 'soapbox/components/ui'; interface IPullToRefresh { children: JSX.Element & React.ReactNode, onRefresh?: () => Promise } /** * PullToRefresh: * Wrapper around a third-party PTR component with Soapbox defaults. */ const PullToRefresh = ({ children, onRefresh, ...rest }: IPullToRefresh) => { const handleRefresh = () => { if (onRefresh) { return onRefresh(); } else { // If not provided, do nothing return Promise.resolve(); } }; return ( } // `undefined` will fallback to the default, while `<>` will render nothing refreshingContent={onRefresh ? : <>} pullDownThreshold={67} maxPullDownDistance={95} resistance={2} {...rest} > {children} ); }; export default PullToRefresh;