Proyectos de Subversion LeadersLinked - Backend

Rev

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

Rev 16000 Rev 16001
Línea 24... Línea 24...
24
  const [showEmojione, setShowEmojione] = useState(false);
24
  const [showEmojione, setShowEmojione] = useState(false);
25
  const [selectedFile, setSelectedFile] = useState("");
25
  const [selectedFile, setSelectedFile] = useState("");
Línea 26... Línea 26...
26
 
26
 
Línea 27... Línea 27...
27
  const { handleSubmit, register } = useForm();
27
  const { handleSubmit, register } = useForm();
28
 
28
 
29
  const bottomToScroll = useRef(null);
29
  const scrollList = useRef(null);
30
  const inputTextEl = useRef(null);
-
 
Línea 31... Línea 30...
31
  const fileInputEl = useRef(null);
30
  const inputTextEl = useRef(null);
32
  const divToScroll = useRef(null);
31
  const fileInputEl = useRef(null);
33
 
32
 
34
  const {
33
  const {
Línea 78... Línea 77...
78
 
77
 
79
  const onIntersection = (entities) => {
78
  const onIntersection = (entities) => {
80
    const target = entities[0];
79
    const target = entities[0];
81
    if (target.isIntersecting && currentPage < totalPages) {
80
    if (target.isIntersecting && currentPage < totalPages) {
82
      setCurrentPage((prevState) => prevState + 1);
81
      setCurrentPage((prevState) => prevState + 1);
83
      bottomToScroll.current.scrollBy(0, 200);
82
      scrollTo(messageList, 200);
84
    }
83
    }
Línea 85... Línea 84...
85
  };
84
  };
86
 
85
 
Línea 96... Línea 95...
96
      })
95
      })
97
      .finally(() => setLoading(false));
96
      .finally(() => setLoading(false));
98
  };
97
  };
Línea 99... Línea 98...
99
 
98
 
100
  //Utilitys
99
  //Utilitys
101
  const scrollToBottom = () => {
100
  const scrollTo = (element, distance) => {
-
 
101
    const divToScrollEl = element.current;
102
    const divToScrollEl = divToScroll.current;
102
    if (!distance) {
-
 
103
      element.current.scrollBy(0, element.current.scrollHeight);
-
 
104
      return;
-
 
105
    }
103
    divToScrollEl.scrollIntoView({ behavior: "smooth" });
106
    element.current.scrollBy(0, distance);
Línea 104... Línea 107...
104
  };
107
  };
105
 
108
 
106
  const onClickEmoji = (event) => {
109
  const onClickEmoji = (event) => {
Línea 127... Línea 130...
127
  const removeSelectedFile = () => {
130
  const removeSelectedFile = () => {
128
    setSelectedFile("");
131
    setSelectedFile("");
129
  };
132
  };
Línea 130... Línea 133...
130
 
133
 
131
  // On send
134
  // On send
132
  const handleKeyDown = (w) => {
135
  const handleKeyDown = (e) => {
133
    if (e.key !== "Enter") return false;
136
    if (e.key !== "Enter") return false;
134
    e.preventDefault();
137
    e.preventDefault();
135
    onHandleSubmit();
138
    onHandleSubmit();
Línea 186... Línea 189...
186
 
189
 
Línea 187... Línea 190...
187
  useEffect(() => axios.post(url_mark_seen), []);
190
  useEffect(() => axios.post(url_mark_seen), []);
188
 
191
 
189
  return (
-
 
190
    <div className={styles.chat}>
-
 
191
      <div className={styles.messagesContainer} ref={bottomToScroll}>
192
  return (
192
        <div ref={divToScroll} />
193
    <div className={styles.chat}>
193
        <MessagesList
194
      <MessagesList
194
          isLastPage={currentPage >= totalPages}
195
        isLastPage={currentPage >= totalPages}
195
          messages={[...oldMessages, ...messages]}
196
        messages={[...oldMessages, ...messages]}
196
          onIntersection={onIntersection}
197
        onIntersection={onIntersection}
197
        />
198
        scrollRef={scrollList}
198
      </div>
199
      />
199
      <div className={styles.chat__input__container}>
200
      <div className={styles.chat__input__container}>
200
        {showEmojione && <Emojione onClickEmoji={onClickEmoji} />}
201
        {showEmojione && <Emojione onClickEmoji={onClickEmoji} />}
201
        <form
202
        <form
Línea 224... Línea 225...
224
            hidden
225
            hidden
225
          />
226
          />
226
          <textarea
227
          <textarea
227
            className={styles.chatInput}
228
            className={styles.chatInput}
228
            placeholder="Escribe un mensaje"
229
            placeholder="Escribe un mensaje"
229
            rows="1"
-
 
230
            ref={inputTextEl}
230
            ref={inputTextEl}
231
            onKeyDown={handleKeyDown}
231
            onKeyDown={handleKeyDown}
232
          />
232
          />
233
          <button type="submit" className={"btn " + styles.send_btn}>
233
          <button type="submit" className={"btn " + styles.send_btn}>
234
            <SendIcon />
234
            <SendIcon />