Rev 5907 | Ir a la última revisión | Autoría | Comparar con el anterior | Ultima modificación | Ver Log |
/* eslint-disable react/prop-types */import React, { useEffect } from 'react'import { useDispatch, useSelector } from 'react-redux'import { fetchFeeds, setCurrentPage } from '../../../../redux/feed/feed.actions'import EmptySection from '../../../../shared/empty-section/EmptySection'import Spinner from '../../../../shared/loading-spinner/Spinner'import ShareModal from '../../../components/share-modal/ShareModal'import Feed from './Feed'const PaginationComponent = React.lazy(() =>import('../../../../shared/pagination/PaginationComponent'))const FeedList = ({ feed, image }) => {const { allFeeds, timelineUrl, pages, currentPage, loading } = useSelector((state) => state.feed)const dispatch = useDispatch()const fetchSpecificFeed = () =>dispatch(fetchFeeds(timelineUrl + '/feed/' + feed, 1))useEffect(() => {if (feed) {return fetchSpecificFeed()} else {return dispatch(fetchFeeds(timelineUrl, currentPage))}}, [timelineUrl, currentPage, feed])const onChangePageHandler = (currentPage) => {dispatch(setCurrentPage(currentPage))dispatch(fetchFeeds(timelineUrl, currentPage))window.scrollTo(0, 0)}if (loading) {return <Spinner />}if (!allFeeds.length) {return <EmptySection message="No hay publicaciones" />}return (<>{allFeeds.map((feed) => {return <Feed key={feed.feed_unique} image={image} {...feed} />})}<React.Suspense fallback={null}><PaginationComponentonChangePage={onChangePageHandler}pages={pages}isRowcurrentActivePage={currentPage}/><ShareModal timelineUrl={timelineUrl} currentPage={currentPage} /></React.Suspense></>)}export default FeedList