Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

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

Rev 4020 Rev 4021
Línea 1... Línea 1...
1
/* eslint-disable react/prop-types */
1
/* eslint-disable react/prop-types */
2
import React, { useEffect, useState } from "react";
2
import React, { useEffect } from "react";
3
import { useDispatch, useSelector } from "react-redux";
3
import { useDispatch, useSelector } from "react-redux";
4
import { fetchFeeds, setCurrentPage } from "../../../redux/feed/feed.actions";
4
import { fetchFeeds, setCurrentPage } from "../../../redux/feed/feed.actions";
5
 
-
 
6
import Spinner from "../../../shared/loading-spinner/Spinner";
-
 
7
import Feed from "../feed/FeedTemplate";
5
import Feed from "../feed/FeedTemplate";
Línea 8... Línea 6...
8
 
6
 
9
const ShareModal = React.lazy(() => import("../share-modal/ShareModal"))
-
 
10
const HomeNews = React.lazy(() => import("../home-section/HomeNews"))
7
const ShareModal = React.lazy(() => import("../share-modal/ShareModal"))
Línea 11... Línea 8...
11
const PaginationComponent = React.lazy(() => import("../../../shared/pagination/PaginationComponent"))
8
const PaginationComponent = React.lazy(() => import("../../../shared/pagination/PaginationComponent"))
Línea 12... Línea 9...
12
 
9
 
Línea 13... Línea 10...
13
const PATH = window.location.pathname
10
const PATH = window.location.pathname
Línea 14... Línea 11...
14
 
11
 
15
// Props object {routeTimeline, feed, image}
-
 
16
 
-
 
17
const FeedSection = ({ feed, image }) => {
-
 
18
 
-
 
19
  const { allFeeds, timelineUrl, pages, currentPage, loading } = useSelector((state) => state.feed)
12
// Props object {routeTimeline, feed, image}
Línea 20... Línea 13...
20
  const [state, setState] = useState({
13
 
Línea 32... Línea 25...
32
    } else {
25
    } else {
33
      return dispatch(fetchFeeds(timelineUrl, currentPage))
26
      return dispatch(fetchFeeds(timelineUrl, currentPage))
34
    }
27
    }
35
  }, []);
28
  }, []);
Línea 36... Línea -...
36
 
-
 
37
  useEffect(async () => {
-
 
38
    if (window.innerWidth < 1000) {
-
 
39
      const { PeopleYouMayKnow } = await import("../../../shared/helpers/people-you-may-know/PeopleYouMayKnow")
-
 
40
 
-
 
41
      setState({ ...state, PeopleYouMayKnow })
-
 
42
    }
-
 
Línea 43... Línea 29...
43
  }, []);
29
 
44
 
30
 
45
  const onChangePageHandler = (currentPage) => {
31
  const onChangePageHandler = (currentPage) => {
46
    dispatch(setCurrentPage(currentPage));
32
    dispatch(setCurrentPage(currentPage));
47
    dispatch(fetchFeeds(timelineUrl, currentPage))
33
    dispatch(fetchFeeds(timelineUrl, currentPage))
Línea 48... Línea -...
48
    window.scrollTo(0, 0);
-
 
49
  };
-
 
50
 
-
 
51
  if (loading) return (
-
 
52
    <div className="w-100 h-100" style={{ display: "grid", placeItems: 'center' }}>
-
 
53
      <Spinner />
-
 
54
    </div>
34
    window.scrollTo(0, 0);
55
  )
35
  };
56
 
36
 
57
  return (
37
  return (
-
 
38
    <>
-
 
39
      {allFeeds.length
58
    <>
40
        ? allFeeds.map((feed, index) => {
59
      {allFeeds.length
41
          if (window.innerWidth < 1000 && index === 5 && PATH.includes('dashboard')) {
60
        ? allFeeds.map((feed, index) =>
-
 
61
          <>
-
 
62
            {
42
            const PeopleYouMayKnow = React.lazy(() => import("../../../shared/helpers/people-you-may-know/PeopleYouMayKnow"))
-
 
43
            return (
-
 
44
              <>
-
 
45
                <PeopleYouMayKnow />
-
 
46
                <Feed
-
 
47
                  feed={feed}
-
 
48
                  key={feed.feed_unique}
63
              (index === 5 && PATH.includes('dashboard')) &&
49
                  owner_shared={feed.owner_shared}
64
              <div className='d-block d-md-none'>
50
                  image={image}
65
                <PeopleYouMayKnow />
51
                />
66
              </div>
52
              </>
67
            }
53
            )
-
 
54
          }
-
 
55
          if (window.innerWidth < 1000 && index === 8 && PATH.includes('dashboard')) {
68
            {
56
            const HomeNews = React.lazy(() => import("../home-section/HomeNews"))
-
 
57
            return (
-
 
58
              <>
-
 
59
                <HomeNews />
-
 
60
                <Feed
-
 
61
                  feed={feed}
-
 
62
                  key={feed.feed_unique}
69
              (index === 8 && PATH.includes('dashboard')) &&
63
                  owner_shared={feed.owner_shared}
70
              < div className='d-block d-md-none'>
64
                  image={image}
-
 
65
                />
-
 
66
              </>
71
                <HomeNews />
67
            )
72
              </div>
68
          }
73
            }
69
          return (
74
            <Feed
70
            <Feed
75
              feed={feed}
71
              feed={feed}
76
              key={feed.feed_unique}
72
              key={feed.feed_unique}
77
              owner_shared={feed.owner_shared}
73
              owner_shared={feed.owner_shared}
78
              image={image}
74
              image={image}
79
            />
75
            />
80
          </>
76
          )
81
        )
77
        })
82
        :
78
        :
83
        <div style={{ display: 'grid', width: '100%', padding: '20px', placeItems: 'center' }}>
79
        <div style={{ display: 'grid', width: '100%', padding: '20px', placeItems: 'center' }}>