Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

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

Rev 3119 Rev 3120
Línea 69... Línea 69...
69
 
69
 
70
function propsAreEqual(prevProp, nextProp) {
70
function propsAreEqual(prevProp, nextProp) {
71
  return prevProp.not_seen_messages === nextProp.not_seen_messages
71
  return prevProp.not_seen_messages === nextProp.not_seen_messages
Línea 72... Línea 72...
72
}
72
}
Línea 73... Línea 73...
73
 
73
 
74
const PersonalChat = ({ entity, index, onClose, onMinimize, onRead, not_seen_messages }) => {
74
const PersonalChat = ({ entity, index, onClose, onMinimize, onRead, not_seen_messages, loading }) => {
75
 
75
 
76
  // entity destructuring
76
  // entity destructuring
Línea 105... Línea 105...
105
  const [availableContactsToAdd, setAvailableContactsToAdd] = useState([]);
105
  const [availableContactsToAdd, setAvailableContactsToAdd] = useState([]);
106
  const [groupContactsList, setGroupContactsList] = useState([]);
106
  const [groupContactsList, setGroupContactsList] = useState([]);
107
  const [confirmModalShow, setConfirmModalShow] = useState(false);
107
  const [confirmModalShow, setConfirmModalShow] = useState(false);
108
  const [showEmojiTab, setShowEmojiTab] = useState(false);
108
  const [showEmojiTab, setShowEmojiTab] = useState(false);
109
  const [shareFileModalShow, setShareFileModalShow] = useState(false);
109
  const [shareFileModalShow, setShareFileModalShow] = useState(false);
110
  const [loading, setLoading] = useState(false);
-
 
Línea 111... Línea 110...
111
 
110
 
112
  // refs
111
  // refs
113
  const conversationListEl = useRef(null);
112
  const conversationListEl = useRef(null);
114
  const loader = useRef(null);
113
  const loader = useRef(null);
Línea 155... Línea 154...
155
  //   });
154
  //   });
156
  //   onRead(index);
155
  //   onRead(index);
157
  // };
156
  // };
Línea 158... Línea 157...
158
 
157
 
159
  const handleGetMessages = async () => {
-
 
160
    setLoading(true)
158
  const handleGetMessages = async () => {
161
    const response = await axios.get(url_get_all_messages);
159
    const response = await axios.get(url_get_all_messages);
162
    const resData = response.data;
160
    const resData = response.data;
163
    if (!resData.success) {
161
    if (!resData.success) {
164
      return ("ha ocurrido un error", resData);
162
      return ("ha ocurrido un error", resData);
Línea 171... Línea 169...
171
      return acum;
169
      return acum;
172
    }, []);
170
    }, []);
Línea 173... Línea 171...
173
 
171
 
174
    if (newMessages.length > 0) {
172
    if (newMessages.length > 0) {
175
      setMessages([...messages, ...newMessages]);
-
 
176
      setLoading(false)
173
      setMessages([...messages, ...newMessages]);
177
      setPages(resData.data.pages);
174
      setPages(resData.data.pages);
178
      scrollToBottom();
175
      scrollToBottom();
179
    } else {
176
    } else {
180
      setMessages([...updatedMessages]);
-
 
181
      setLoading(false)
177
      setMessages([...updatedMessages]);
182
    }
178
    }
Línea 183... Línea 179...
183
  };
179
  };
184
 
180
 
Línea 335... Línea 331...
335
    };
331
    };
336
  }, [currentPage]);
332
  }, [currentPage]);
Línea 337... Línea 333...
337
 
333
 
338
  // getMessagesInterval
334
  // getMessagesInterval
-
 
335
  useEffect(() => {
339
  useEffect(() => {
336
    let timer;
340
    if (window.location.pathname === '/group/my-groups') {
337
    if (window.location.pathname === '/group/my-groups') {
341
      const items = document.getElementsByClassName('sc-jSgupP')
338
      const items = document.getElementsByClassName('sc-jSgupP')
342
      if (items && items.length > 0)
339
      if (items && items.length > 0)
343
        items[0].style.display = 'none';
340
        items[0].style.display = 'none';
344
    }
341
    }
-
 
342
    if (!minimized && !loading) {
-
 
343
      timer = () => setTimeout(() => handleGetMessages(), 2000);
345
    if (!minimized && !loading) {
344
 
-
 
345
      timer()
346
      setTimeout(() => {
346
    }
347
        handleGetMessages();
347
    return () => {
348
      }, 1000);
348
      clearTimeout(timer)
349
    }
349
    }
350
  }, [minimized, loading]);
350
  }, [minimized, loading]);
351
 
351
  
352
  const handleConfirmModalShow = () => {
352
  const handleConfirmModalShow = () => {
353
    setConfirmModalShow(!confirmModalShow);
353
    setConfirmModalShow(!confirmModalShow);
Línea 354... Línea 354...
354
  };
354
  };