Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

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

Rev 5185 Rev 5190
Línea 3... Línea 3...
3
import React, { useEffect, useRef, useState } from 'react'
3
import React, { useEffect, useRef, useState } from 'react'
4
import EmptySection from '../../shared/empty-section/EmptySection'
4
import EmptySection from '../../shared/empty-section/EmptySection'
5
import SearchIcon from '@mui/icons-material/Search'
5
import SearchIcon from '@mui/icons-material/Search'
6
import { axios } from '../../utils'
6
import { axios } from '../../utils'
7
import { Modal } from 'react-bootstrap'
7
import { Modal } from 'react-bootstrap'
-
 
8
import { addNotification } from '../../redux/notification/notification.actions'
-
 
9
import { useDispatch } from 'react-redux'
Línea 8... Línea 10...
8
 
10
 
Línea 9... Línea 11...
9
let path_id = window.location.pathname.split('/inmail/')[1]
11
let path_id = window.location.pathname.split('/inmail/')[1]
10
 
12
 
Línea 14... Línea 16...
14
}) => {
16
}) => {
15
  const [conversations, setConversations] = useState([])
17
  const [conversations, setConversations] = useState([])
16
  const [searchActive, setSearchActive] = useState(false)
18
  const [searchActive, setSearchActive] = useState(false)
17
  const [search, setSearch] = useState('')
19
  const [search, setSearch] = useState('')
18
  const [visible, setVisible] = useState(false)
20
  const [visible, setVisible] = useState(false)
-
 
21
  const [loading, setLoading] = useState(false)
-
 
22
  const dispatch = useDispatch()
19
  const searchContainer = useRef()
23
  const searchContainer = useRef()
Línea 20... Línea 24...
20
 
24
 
Línea 21... Línea 25...
21
  const filtredConversations = conversations.filter((conversation) => conversation.name.toLowerCase().includes(search.toLowerCase()))
25
  const filtredConversations = conversations.filter((conversation) => conversation.name.toLowerCase().includes(search.toLowerCase()))
22
 
26
 
-
 
27
  const load = async () => {
23
  const load = async () => {
28
    try {
24
    try {
29
      setLoading(true)
25
      const { data } = await axios.get(window.location.href)
30
      const { data } = await axios.get(window.location.href)
26
      if (data.success) setConversations(data.data)
31
      if (data.success) setConversations(data.data)
-
 
32
    } catch (error) {
-
 
33
      const errorMessage = new Error(error)
-
 
34
      dispatch(addNotification({ style: 'danger', msg: errorMessage.message }))
27
    } catch (error) {
35
    } finally {
28
      console.log('>>: error > ', error)
36
      setLoading(false)
Línea 29... Línea 37...
29
    }
37
    }
30
  }
38
  }
Línea 57... Línea 65...
57
    return () => {
65
    return () => {
58
      clearInterval(interval)
66
      clearInterval(interval)
59
    }
67
    }
60
  }, [])
68
  }, [])
Línea -... Línea 69...
-
 
69
 
-
 
70
  useEffect(() => {
-
 
71
    let timer
-
 
72
    if (!loading) {
-
 
73
      timer = setTimeout(() => {
-
 
74
        load()
-
 
75
      }, 2000)
-
 
76
    }
-
 
77
    return () => {
-
 
78
      clearTimeout(timer)
-
 
79
    }
-
 
80
  }, [loading])
61
 
81
 
62
  return (
82
  return (
63
    <>
83
    <>
64
      <Sidebar.StartConversationModal
84
      <Sidebar.StartConversationModal
65
        show={visible}
85
        show={visible}