Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

Rev 691 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 691 Rev 976
Línea 1... Línea 1...
1
import React, {useCallback} from "react";
1
import React, { useCallback } from "react";
2
import { useState, useEffect } from "react";
2
import { useState, useEffect } from "react";
3
import {axios} from "../../utils";
3
import { axios } from "../../utils";
4
import Contacts from "./contacts/Contacts";
4
import Contacts from "./contacts/Contacts";
5
import Groups from "./groups/Groups";
5
import Groups from "./groups/Groups";
6
import PersonalChat from "./personal-chat/PersonalChat";
6
import PersonalChat from "./personal-chat/PersonalChat";
Línea 7... Línea 7...
7
 
7
 
Línea 16... Línea 16...
16
  const [isChatOpen, setIsChatOpen] = useState(false);
16
  const [isChatOpen, setIsChatOpen] = useState(false);
17
  const [isMuted, setIsMuted] = useState(false);
17
  const [isMuted, setIsMuted] = useState(false);
18
  const [activeTab, setActiveTab] = useState("user");
18
  const [activeTab, setActiveTab] = useState("user");
19
  const defaultChatInterval = 1500;
19
  const defaultChatInterval = 1500;
20
  const [chatInterval, setChatInterval] = useState(defaultChatInterval);
20
  const [chatInterval, setChatInterval] = useState(defaultChatInterval);
-
 
21
  const [search, setSearch] = useState('');
-
 
22
 
-
 
23
  const filtredContacts = contacts.filter(({ name }) => name.includes())
-
 
24
 
21
  // Time intervals
25
  // Time intervals
22
  let heartBeatInterval;
26
  let heartBeatInterval;
23
  const handleEntities = entities =>{
27
  const handleEntities = entities => {
24
    setFullChats([...entities]);
28
    setFullChats([...entities]);
25
    let newUserContacts = [];
29
    let newUserContacts = [];
26
    let newGroups = [];
30
    let newGroups = [];
27
    entities.map((entity) => {
31
    entities.map((entity) => {
28
      if (entity.is_open) {
32
      if (entity.is_open) {
Línea 55... Línea 59...
55
        entities = resData.data;
59
        entities = resData.data;
56
        handleEntities(entities);
60
        handleEntities(entities);
57
      }
61
      }
58
      return entities;
62
      return entities;
59
    } catch (error) {
63
    } catch (error) {
60
      console.log('>>: chat error > ', error) 
64
      console.log('>>: chat error > ', error)
61
    }
65
    }
62
  };
66
  };
63
  
67
 
64
  
68
 
Línea 65... Línea 69...
65
 
69
 
66
  const handleUpdateOnline = (entity) => {
70
  const handleUpdateOnline = (entity) => {
67
    const existingChatId = activeChats.findIndex(
71
    const existingChatId = activeChats.findIndex(
68
      (activeChat) => activeChat.id === entity.id
72
      (activeChat) => activeChat.id === entity.id
Línea 76... Línea 80...
76
    }
80
    }
77
  };
81
  };
Línea 78... Línea 82...
78
 
82
 
79
  const handleNewMessage = async (unseeEntity) => {
83
  const handleNewMessage = async (unseeEntity) => {
80
    await axios.post(unseeEntity.url_mark_received).then((response) => {
84
    await axios.post(unseeEntity.url_mark_received).then((response) => {
81
       ('')
85
      ('')
82
    });
86
    });
83
    if (!activeChats.some((activeChat) => activeChat.id === unseeEntity.id)) {
87
    if (!activeChats.some((activeChat) => activeChat.id === unseeEntity.id)) {
84
      setActiveChats([...activeChats, { ...unseeEntity, minimized: false }]);
88
      setActiveChats([...activeChats, { ...unseeEntity, minimized: false }]);
85
      playNotifyAudio();
89
      playNotifyAudio();
Línea 153... Línea 157...
153
  };
157
  };
Línea 154... Línea 158...
154
 
158
 
155
  useEffect(() => {
159
  useEffect(() => {
156
    let entities = [];
160
    let entities = [];
157
    clearInterval(heartBeatInterval);
161
    clearInterval(heartBeatInterval);
158
    heartBeatInterval = setInterval(async() => {
162
    heartBeatInterval = setInterval(async () => {
159
      entities = await heartBeat() || [];
163
      entities = await heartBeat() || [];
160
    }, chatInterval);
164
    }, chatInterval);
161
    if((entities === fullChats) && (chatInterval !== defaultChatInterval * 2)){
165
    if ((entities === fullChats) && (chatInterval !== defaultChatInterval * 2)) {
162
      clearInterval(heartBeatInterval);
166
      clearInterval(heartBeatInterval);
163
      setChatInterval(defaultChatInterval * 2);
167
      setChatInterval(defaultChatInterval * 2);
164
    }
168
    }
165
    return () => {
169
    return () => {
Línea 205... Línea 209...
205
                    <span
209
                    <span
206
                      className="min localhost-icon-minus-1"
210
                      className="min localhost-icon-minus-1"
207
                      id="mute-sound"
211
                      id="mute-sound"
208
                    >
212
                    >
209
                      <i
213
                      <i
210
                        className={`icon ${
-
 
211
                          isMuted ? "icon-volume-off" : "icon-volume-2"
214
                        className={`icon ${isMuted ? "icon-volume-off" : "icon-volume-2"
212
                        } text-20`}
215
                          } text-20`}
213
                        aria-hidden="true"
216
                        aria-hidden="true"
214
                        onClick={handleMute}
217
                        onClick={handleMute}
215
                      ></i>
218
                      ></i>
216
                    </span>
219
                    </span>
217
                    {/* <span
220
                    {/* <span
Línea 239... Línea 242...
239
                          className="drupalchat_searchinput live-search-box"
242
                          className="drupalchat_searchinput live-search-box"
240
                          id="live-search-box"
243
                          id="live-search-box"
241
                          placeholder="Buscar"
244
                          placeholder="Buscar"
242
                          size="24"
245
                          size="24"
243
                          type="text"
246
                          type="text"
-
 
247
                          name='search'
-
 
248
                          value={search}
-
 
249
                          onChange={e => {
-
 
250
                            setSearch(e.target.value || '')
-
 
251
                          }}
244
                        />
252
                        />
245
                        <button
253
                        <button
246
                          className="searchbutton"
254
                          className="searchbutton"
247
                          id="searchbutton"
255
                          id="searchbutton"
248
                          title=""
256
                          title=""
Línea 318... Línea 326...
318
                      style={{
326
                      style={{
319
                        display: activeTab === "user" ? "block" : "none",
327
                        display: activeTab === "user" ? "block" : "none",
320
                      }}
328
                      }}
321
                    >
329
                    >
322
                      <Contacts
330
                      <Contacts
323
                        contacts={contacts}
331
                        contacts={filtredContacts}
324
                        onOpenConversation={handleOpenConversation}
332
                        onOpenConversation={handleOpenConversation}
325
                      />
333
                      />
326
                    </div>
334
                    </div>
327
                    <div
335
                    <div
328
                      className="group-list chatboxcontent"
336
                      className="group-list chatboxcontent"