Proyectos de Subversion LeadersLinked - Backend

Rev

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

Rev 15844 Rev 15851
Línea 2... Línea 2...
2
import { axios } from "../../../utils";
2
import { axios } from "../../../utils";
3
import { useForm } from "react-hook-form";
3
import { useForm } from "react-hook-form";
Línea 4... Línea 4...
4
 
4
 
5
import Emojione from "./emojione/Emojione";
5
import Emojione from "./emojione/Emojione";
6
import FileModal from "./fileModal/FileModal";
6
import FileModal from "./fileModal/FileModal";
7
import Messages from "./messages/Messages";
7
import MessagesList from "./messages/MessagesList";
8
import AttachFileIcon from "@mui/icons-material/AttachFile";
8
import AttachFileIcon from "@mui/icons-material/AttachFile";
9
import InsertEmoticonIcon from "@mui/icons-material/InsertEmoticon";
9
import InsertEmoticonIcon from "@mui/icons-material/InsertEmoticon";
Línea 10... Línea 10...
10
import SendIcon from "@mui/icons-material/Send";
10
import SendIcon from "@mui/icons-material/Send";
Línea 27... Línea 27...
27
  const { handleSubmit, register } = useForm();
27
  const { handleSubmit, register } = useForm();
Línea 28... Línea 28...
28
 
28
 
29
  const bottomToScroll = useRef(null);
29
  const bottomToScroll = useRef(null);
30
  const inputTextEl = useRef(null);
30
  const inputTextEl = useRef(null);
31
  const fileInputEl = useRef(null);
-
 
-
 
31
  const fileInputEl = useRef(null);
32
  const loadMoreEl = useRef();
32
 
Línea 33... Línea 33...
33
  const divToScroll = useRef(null);
33
  const divToScroll = useRef(null);
34
 
34
 
35
  const {
35
  const {
Línea 75... Línea 75...
75
        }
75
        }
76
      })
76
      })
77
      .finally(() => setLoading(false));
77
      .finally(() => setLoading(false));
78
  };
78
  };
Línea 79... Línea 79...
79
 
79
 
80
  const onIntersection = async (entities) => {
80
  const onIntersection = (entities) => {
81
    const target = entities[0];
81
    const target = entities[0];
82
    if (target.isIntersecting) {
82
    if (target.isIntersecting) {
83
      if (currentPage < totalPages) {
83
      if (currentPage < totalPages) {
84
        setCurrentPage((prevState) => prevState + 1);
84
        setCurrentPage((prevState) => prevState + 1);
Línea 165... Línea 165...
165
    return () => {
165
    return () => {
166
      clearTimeout(timeInterval);
166
      clearTimeout(timeInterval);
167
    };
167
    };
168
  }, [loading, entity]);
168
  }, [loading, entity]);
Línea 169... Línea -...
169
 
-
 
170
  // infiniteScroll
-
 
171
  useEffect(() => {
-
 
172
    const options = {
-
 
173
      root: null,
-
 
174
      rootMargin: "0px",
-
 
175
      threshold: 1.0,
-
 
176
    };
-
 
177
    const observer = new IntersectionObserver(onIntersection, options);
-
 
178
    if (loadMoreEl.current) {
-
 
179
      observer.observe(loadMoreEl.current);
-
 
180
    }
-
 
181
    return () => {
-
 
182
      observer.disconnect();
-
 
183
    };
-
 
184
  }, [totalPages]);
-
 
185
 
169
 
186
  useEffect(() => {
170
  useEffect(() => {
187
    getAllMessages();
171
    getAllMessages();
Línea 188... Línea 172...
188
  }, [currentPage]);
172
  }, [currentPage]);
Línea 192... Línea 176...
192
  }, []);
176
  }, []);
Línea 193... Línea 177...
193
 
177
 
194
  return (
178
  return (
195
    <div className={styles.chat}>
179
    <div className={styles.chat}>
196
      <div className={styles.messagesContainer} ref={bottomToScroll}>
-
 
197
        <div className={styles.messageWrapper}>
-
 
198
          {currentPage < totalPages && (
-
 
199
            <p ref={loadMoreEl} className="mt-2">
-
 
200
              Cargando...
-
 
201
            </p>
-
 
202
          )}
180
      <div className={styles.messagesContainer} ref={bottomToScroll}>
203
          <Messages
181
        <MessagesList
204
            oldMessages={oldMessages}
182
          isLastPage={currentPage >= totalPages}
205
            newMessages={messages}
183
          messages={[...oldMessages, ...messages]}
206
            onScrollToBottom={scrollToBottom}
-
 
207
            chatType={type}
184
          onIntersection={onIntersection}
208
          />
185
        />
209
          <div ref={divToScroll}></div>
-
 
210
        </div>
186
        <div ref={divToScroll} />
211
      </div>
187
      </div>
212
      <div className={styles.chat__input__container}>
188
      <div className={styles.chat__input__container}>
213
        {showEmojione && <Emojione onClickEmoji={onClickEmoji} />}
189
        {showEmojione && <Emojione onClickEmoji={onClickEmoji} />}
214
        <form
190
        <form