Proyectos de Subversion LeadersLinked - Backend

Rev

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

Rev 15860 Rev 15880
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);
-
 
32
 
31
  const fileInputEl = useRef(null);
Línea 33... Línea 32...
33
  const divToScroll = useRef(null);
32
  const divToScroll = useRef(null);
34
 
33
 
35
  const {
34
  const {
Línea 77... Línea 76...
77
      .finally(() => setLoading(false));
76
      .finally(() => setLoading(false));
78
  };
77
  };
Línea 79... Línea 78...
79
 
78
 
80
  const onIntersection = (entities) => {
79
  const onIntersection = (entities) => {
81
    const target = entities[0];
-
 
82
    if (target.isIntersecting) {
80
    const target = entities[0];
83
      if (currentPage < totalPages) {
81
    if (target.isIntersecting && currentPage < totalPages) {
84
        setCurrentPage((prevState) => prevState + 1);
82
      setCurrentPage((prevState) => prevState + 1);
85
        bottomToScroll.current.scrollBy(0, 200);
-
 
86
      }
83
      bottomToScroll.current.scrollBy(0, 200);
87
    }
84
    }
Línea 88... Línea 85...
88
  };
85
  };
89
 
86
 
Línea 106... Línea 103...
106
    divToScrollEl.scrollIntoView({ behavior: "smooth" });
103
    divToScrollEl.scrollIntoView({ behavior: "smooth" });
107
  };
104
  };
Línea 108... Línea 105...
108
 
105
 
109
  const onClickEmoji = (event) => {
106
  const onClickEmoji = (event) => {
110
    const shortname = event.currentTarget.dataset.shortname;
-
 
111
    const currentText = inputTextEl.current.value;
-
 
112
    let cursorPosition = inputTextEl.current.selectionStart;
-
 
113
    const textBehind = currentText.substring(0, cursorPosition);
-
 
-
 
107
    const shortname = event.currentTarget.dataset.shortname;
114
    const textForward = currentText.substring(cursorPosition);
108
 
115
    inputTextEl.current.value = `${textBehind}${shortname}${textForward}`;
109
    inputTextEl.current.value += shortname;
116
    inputTextEl.current.focus();
-
 
117
    inputTextEl.current.setSelectionRange(
-
 
118
      cursorPosition + shortname.length,
-
 
119
      cursorPosition + shortname.length
-
 
120
    );
110
    inputTextEl.current.focus();
Línea 121... Línea 111...
121
  };
111
  };
122
 
112
 
-
 
113
  const handleUploadFile = ({ target }) => {
-
 
114
    const file = target.files[0];
-
 
115
 
-
 
116
    if (!file) {
-
 
117
      return;
123
  const handleUploadFile = (e) => {
118
    }
124
    const file = e.target.files[0];
119
 
Línea 125... Línea 120...
125
    if (file) setSelectedFile(file);
120
    setSelectedFile(file);
126
  };
121
  };
127
 
122
 
Línea 128... Línea 123...
128
  const removeSelectedFile = () => {
123
  const removeSelectedFile = () => {
129
    setSelectedFile("");
124
    setSelectedFile("");
130
  };
125
  };
131
 
126
 
132
  // On send
-
 
133
  const onHandleSubmit = (data, event) => {
-
 
134
    const formData = new FormData();
127
  // On send
135
    Object.entries(data).map(([key, value]) => {
128
  const onHandleSubmit = (data, event) => {
136
      formData.append(key, value);
-
 
137
    });
-
 
138
    event.target.reset();
129
    const formData = new FormData();
Línea 139... Línea 130...
139
    axios.post(url_send, formData).then((response) => {
130
    Object.entries(data).map(([key, value]) => formData.append(key, value));
140
      setShowEmojione(false);
131
    event.target.reset();
141
    });
132
    axios.post(url_send, formData).then((response) => setShowEmojione(false));
142
  };
133
  };
143
 
134
 
144
  const handleSendFile = () => {
135
  const handleSendFile = () => {
145
    const formData = new FormData();
136
    const formData = new FormData();
146
    formData.append("file", selectedFile);
137
    formData.append("file", selectedFile);
147
    axios.post(url_upload, formData).then(async (response) => {
138
    axios.post(url_upload, formData).then(({ data: response }) => {
-
 
139
      const { success, data } = response;
-
 
140
      if (!success) {
148
      const resData = response.data;
141
        console.log("Ha ocurrido un error: " + data);
149
      if (resData.success) {
142
        return;
Línea 150... Línea 143...
150
        setSelectedFile("");
143
      }
151
        setShowEmojione(false);
144
      setSelectedFile("");
Línea 159... Línea 152...
159
    timeInterval = setTimeout(() => getMessages(), 2000);
152
    timeInterval = setTimeout(() => getMessages(), 2000);
Línea 160... Línea 153...
160
 
153
 
161
    return () => {
154
    return () => {
162
      clearTimeout(timeInterval);
155
      clearTimeout(timeInterval);
163
    };
156
    };
Línea 164... Línea 157...
164
  }, [loading, entity]);
157
  }, [loading]);
-
 
158
 
165
 
159
  useEffect(() => {
-
 
160
    setMessages([]);
166
  useEffect(() => {
161
    setOldMessages([]);
-
 
162
    setTotalPages(1);
Línea 167... Línea 163...
167
    getOldMessages();
163
    setCurrentPage(1);
-
 
164
  }, [entity]);
168
  }, [currentPage]);
165
 
169
 
-
 
Línea 170... Línea 166...
170
  useEffect(() => {
166
  useEffect(() => getOldMessages(), [currentPage]);
171
    axios.post(url_mark_seen);
167
 
172
  }, []);
168
  useEffect(() => axios.post(url_mark_seen), []);
173
 
169