Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

Rev 5248 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 5248 Rev 6301
Línea 1... Línea 1...
1
import React from 'react'
1
import React from 'react'
Línea 2... Línea 2...
2
 
2
 
-
 
3
const jsonToParams = (data = {}) => {
3
const jsonToParams = (data = {}) => {
4
  if (!data) {
-
 
5
    return false
4
  if (!data) { return false } else {
6
  } else {
5
    const formBody = []
7
    const formBody = []
6
    for (const property in data) {
8
    for (const property in data) {
7
      const encodedKey = encodeURIComponent(property)
9
      const encodedKey = encodeURIComponent(property)
8
      // @ts-ignore
10
      // @ts-ignore
Línea 15... Línea 17...
15
}
17
}
Línea 16... Línea 18...
16
 
18
 
17
const useWindowSize = () => {
19
const useWindowSize = () => {
18
  const [size, setSize] = React.useState([0, 0])
20
  const [size, setSize] = React.useState([0, 0])
19
  React.useLayoutEffect(() => {
21
  React.useLayoutEffect(() => {
20
    function updateSize () {
22
    function updateSize() {
21
      setSize([window.innerWidth, window.innerHeight])
23
      setSize([window.innerWidth, window.innerHeight])
22
    }
24
    }
23
    window.addEventListener('resize', updateSize)
25
    window.addEventListener('resize', updateSize)
24
    updateSize()
26
    updateSize()
25
    return () => window.removeEventListener('resize', updateSize)
27
    return () => window.removeEventListener('resize', updateSize)
26
  }, [])
28
  }, [])
27
  return size
29
  return size
Línea -... Línea 30...
-
 
30
}
-
 
31
 
-
 
32
const filterItems = (query = '', items = []) => {
-
 
33
  if (!query) {
-
 
34
    return items
-
 
35
  }
-
 
36
 
-
 
37
  return items.filter((conversation) =>
-
 
38
    conversation.name.toLowerCase().includes(query.toLowerCase())
-
 
39
  )
28
}
40
}
29
 
41
 
30
const debounce = (func, timeout = 300) => {
42
const debounce = (func, timeout = 300) => {
31
  let timer
43
  let timer
32
  return (...args) => {
44
  return (...args) => {
-
 
45
    clearTimeout(timer)
-
 
46
    timer = setTimeout(() => {
33
    clearTimeout(timer)
47
      func.apply(this, args)
34
    timer = setTimeout(() => { func.apply(this, args) }, timeout)
48
    }, timeout)
Línea 35... Línea 49...
35
  }
49
  }
36
}
50
}
Línea 41... Línea 55...
41
  }
55
  }
Línea 42... Línea 56...
42
 
56
 
43
  element.scrollTop = element.scrollHeight * 9
57
  element.scrollTop = element.scrollHeight * 9
Línea 44... Línea -...
44
}
-
 
45
 
-
 
46
export {
-
 
47
  useWindowSize,
-
 
48
  jsonToParams,
58
}
49
  debounce,
-