Proyectos de Subversion LeadersLinked - SPA

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1684 stevensc 1
import React, { useEffect } from 'react'
2
import { Box, styled } from '@mui/material'
3
 
4
import useNearScreen from '@app/hooks/useNearScreen'
5
 
6
import Message from './message'
7
 
8
const MessagesContainer = styled(Box)`
9
  gap: 0.5rem;
10
  display: flex;
11
  flex-direction: column-reverse;
12
  height: -webkit-fill-available;
13
  padding: 0.5rem 0;
14
  overflow: auto;
15
`
16
 
17
export default function MessagesList({
18
  messages = [],
19
  onPagination,
20
  onReport,
21
  scrollRef,
22
  loading
23
}) {
24
  const [isIntercepting, ref] = useNearScreen({
25
    once: false,
26
    rootMargin: '0px'
27
  })
28
 
29
  useEffect(() => {
30
    if (isIntercepting) {
31
      onPagination()
32
    }
33
  }, [isIntercepting])
34
 
35
  return (
36
    <MessagesContainer ref={scrollRef}>
37
      {messages.map((message) => (
38
        <Message onReport={onReport} message={message} key={message.id} />
39
      ))}
40
 
41
      <p ref={ref}>Loading</p>
42
    </MessagesContainer>
43
  )
44
}