Proyectos de Subversion LeadersLinked - SPA

Rev

Rev 1609 | Rev 1651 | Ir a la última revisión | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 1609 Rev 1650
Línea 1... Línea 1...
1
import React, { useEffect } from 'react'
1
import React from 'react'
2
import { useDispatch, useSelector } from 'react-redux'
-
 
Línea 3... Línea 2...
3
 
2
 
4
import Feed from '../feed-template/Feed'
-
 
5
import Spinner from '@app/components/UI/Spinner'
3
import Feed from '../feed-template/Feed'
6
import EmptySection from '@app/components/UI/EmptySection'
-
 
Línea 7... Línea -...
7
import { fetchFeeds, setCurrentPage } from '@app/redux/feed/feed.actions'
-
 
8
 
-
 
9
const PaginationComponent = React.lazy(() =>
-
 
10
  import('../../../UI/PaginationComponent')
-
 
11
)
4
import EmptySection from '@app/components/UI/EmptySection'
12
 
-
 
13
const FeedList = ({ feed, image }) => {
-
 
14
  const { allFeeds, timelineUrl, pages, currentPage, loading } = useSelector(
-
 
15
    ({ feed }) => feed
-
 
16
  )
-
 
17
  const dispatch = useDispatch()
-
 
18
 
-
 
19
  const fetchSpecificFeed = () =>
-
 
20
    dispatch(fetchFeeds(timelineUrl + '/feed/' + feed, 1))
-
 
21
 
-
 
22
  const onChangePageHandler = (currentPage) => {
-
 
23
    dispatch(setCurrentPage(currentPage))
-
 
24
    window.scrollTo(0, 0)
-
 
25
  }
-
 
26
 
-
 
27
  useEffect(() => {
-
 
28
    dispatch(setCurrentPage(1))
-
 
29
  }, [])
-
 
30
 
-
 
31
  useEffect(() => {
-
 
32
    feed ? fetchSpecificFeed() : dispatch(fetchFeeds(timelineUrl, currentPage))
-
 
33
  }, [timelineUrl, currentPage, feed])
-
 
34
 
-
 
35
  if (loading) {
-
 
36
    return <Spinner />
-
 
37
  }
5
 
38
 
6
const FeedList = ({ feeds = [], image = '' }) => {
39
  if (!allFeeds.length) {
7
  if (!feeds.length) {
Línea 40... Línea 8...
40
    return <EmptySection message='No hay publicaciones' />
8
    return <EmptySection message='No hay publicaciones' />
41
  }
9
  }
42
 
10
 
43
  return (
11
  return (
44
    <>
12
    <>
45
      {allFeeds.map((feed) => {
-
 
46
        return <Feed key={feed.feed_uuid} image={image} {...feed} />
-
 
47
      })}
-
 
48
      <React.Suspense fallback={null}>
-
 
49
        <PaginationComponent
-
 
50
          pages={pages}
-
 
51
          currentActivePage={currentPage}
-
 
52
          onChangePage={onChangePageHandler}
-
 
53
          isRow
13
      {feeds.map((feed) => (
54
        />
14
        <Feed key={feed.feed_uuid} image={image} {...feed} />
55
      </React.Suspense>
15
      ))}
Línea 56... Línea 16...
56
    </>
16
    </>