Proyectos de Subversion LeadersLinked - SPA

Rev

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

Rev 200 Rev 697
Línea 1... Línea 1...
1
import React, { useEffect } from "react";
1
import React, { useEffect } from 'react'
2
import { useDispatch, useSelector } from "react-redux";
2
import { useDispatch, useSelector } from 'react-redux'
3
import {
-
 
4
  fetchFeeds,
-
 
5
  setCurrentPage,
-
 
6
} from "../../../../redux/feed/feed.actions";
3
import { fetchFeeds, setCurrentPage } from '../../../../redux/feed/feed.actions'
7
 
4
 
8
import Feed from "../feed-template/Feed";
5
import Feed from '../feed-template/Feed'
9
import Spinner from "../../../UI/Spinner";
6
import Spinner from '../../../UI/Spinner'
10
import EmptySection from "../../../UI/EmptySection";
7
import EmptySection from '../../../UI/EmptySection'
11
import ShareModal from "../../../share-modal/ShareModal";
8
import ShareModal from '../../../share-modal/ShareModal'
Línea 12... Línea 9...
12
 
9
 
13
const PaginationComponent = React.lazy(() =>
10
const PaginationComponent = React.lazy(() =>
14
  import("../../../UI/PaginationComponent")
11
  import('../../../UI/PaginationComponent')
Línea 15... Línea 12...
15
);
12
)
16
 
13
 
17
const FeedList = ({ feed, image }) => {
14
const FeedList = ({ feed, image }) => {
18
  const { allFeeds, timelineUrl, pages, currentPage, loading } = useSelector(
15
  const { allFeeds, timelineUrl, pages, currentPage, loading } = useSelector(
19
    ({ feed }) => feed
16
    ({ feed }) => feed
Línea 20... Línea 17...
20
  );
17
  )
21
  const dispatch = useDispatch();
18
  const dispatch = useDispatch()
Línea 22... Línea 19...
22
 
19
 
23
  const fetchSpecificFeed = () =>
20
  const fetchSpecificFeed = () =>
24
    dispatch(fetchFeeds(timelineUrl + "/feed/" + feed, 1));
21
    dispatch(fetchFeeds(timelineUrl + '/feed/' + feed, 1))
25
 
22
 
Línea 26... Línea 23...
26
  const onChangePageHandler = (currentPage) => {
23
  const onChangePageHandler = (currentPage) => {
27
    dispatch(setCurrentPage(currentPage));
24
    dispatch(setCurrentPage(currentPage))
28
    window.scrollTo(0, 0);
25
    window.scrollTo(0, 0)
Línea 29... Línea 26...
29
  };
26
  }
30
 
27
 
31
  useEffect(() => {
28
  useEffect(() => {
32
    dispatch(setCurrentPage(1));
29
    dispatch(setCurrentPage(1))
33
  }, []);
30
  }, [])
34
 
31
 
35
  useEffect(() => {
32
  useEffect(() => {
Línea 36... Línea 33...
36
    if (feed) {
33
    if (feed) {
37
      fetchSpecificFeed();
34
      fetchSpecificFeed()
38
    } else {
35
    } else {
Línea 39... Línea 36...
39
      dispatch(fetchFeeds(timelineUrl, currentPage));
36
      dispatch(fetchFeeds(timelineUrl, currentPage))
-
 
37
    }
-
 
38
  }, [timelineUrl, currentPage, feed])
40
    }
39
 
-
 
40
  if (loading) {
-
 
41
    return <Spinner />
-
 
42
  }
41
  }, [timelineUrl, currentPage, feed]);
43
 
Línea 42... Línea 44...
42
 
44
  if (!allFeeds.length) {
43
  if (loading) {
45
    return (
44
    return <Spinner />;
46
      <>
45
  }
47
        <EmptySection message='No hay publicaciones' />;
46
 
48
        <ShareModal timelineUrl={timelineUrl} currentPage={currentPage} />
47
  if (!allFeeds.length) {
49
      </>
48
    return <EmptySection message="No hay publicaciones" />;
50
    )
49
  }
51
  }
50
 
52
 
Línea 61... Línea 63...
61
          currentActivePage={currentPage}
63
          currentActivePage={currentPage}
62
        />
64
        />
63
        <ShareModal timelineUrl={timelineUrl} currentPage={currentPage} />
65
        <ShareModal timelineUrl={timelineUrl} currentPage={currentPage} />
64
      </React.Suspense>
66
      </React.Suspense>
65
    </>
67
    </>
66
  );
68
  )
67
};
69
}
Línea 68... Línea 70...
68
 
70