Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

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

Rev 3090 Rev 3094
Línea -... Línea 1...
-
 
1
/* eslint-disable react/prop-types */
1
import React from "react";
2
import React from "react";
2
import { useState, useRef, useEffect } from "react";
3
import { useState, useRef, useEffect } from "react";
3
import styled from "styled-components";
4
import styled from "styled-components";
4
import { axios } from "../../../utils";
5
import { axios } from "../../../utils";
5
import Spinner from "../../../shared/loading-spinner/Spinner";
-
 
6
import Emojione from "./emojione/Emojione";
6
import Emojione from "./emojione/Emojione";
7
import SendFileModal from "./send-file-modal/SendFileModal";
7
import SendFileModal from "./send-file-modal/SendFileModal";
8
import ConfirmModal from "../../../shared/confirm-modal/ConfirmModal";
8
import ConfirmModal from "../../../shared/confirm-modal/ConfirmModal";
9
import MessageTemplate from "./messageTemplate/MessageTemplate";
9
import MessageTemplate from "./messageTemplate/MessageTemplate";
10
import { data } from "autoprefixer";
-
 
Línea 11... Línea 10...
11
 
10
 
12
const StyledChatHead = styled.div`
11
const StyledChatHead = styled.div`
13
  .notify {
12
  .notify {
14
    animation: notify 2s infinite;
13
    animation: notify 2s infinite;
Línea 75... Línea 74...
75
    id,
74
    id,
76
    image,
75
    image,
77
    name,
76
    name,
78
    online,
77
    online,
79
    type,
78
    type,
80
    unsee_messages,
79
    not_seen_messages,
81
    url_clear,
80
    url_clear,
82
    url_close,
81
    url_close,
83
    url_get_all_messages,
82
    url_get_all_messages,
84
    url_send,
83
    url_send,
85
    url_upload,
84
    url_upload,
Línea 95... Línea 94...
95
  } = entity;
94
  } = entity;
Línea 96... Línea 95...
96
 
95
 
97
  // states
96
  // states
98
  const [messages, setMessages] = useState([]);
97
  const [messages, setMessages] = useState([]);
99
  const [responseMessage, setResponseMessage] = useState(null);
-
 
100
  const [newMessages, setNewMessages] = useState([]);
98
  const [responseMessage, setResponseMessage] = useState(null);
101
  const [oldMessages, setOldMessages] = useState([]);
99
  const [oldMessages, setOldMessages] = useState([]);
102
  const [currentPage, setCurrentPage] = useState(1);
100
  const [currentPage, setCurrentPage] = useState(1);
103
  const [pages, setPages] = useState(1);
-
 
104
  const [loading, setLoading] = useState(false);
101
  const [pages, setPages] = useState(1);
105
  const [showOptions, setShowOptions] = useState(false);
102
  const [showOptions, setShowOptions] = useState(false);
106
  const [optionTab, setOptionTab] = useState("default");
103
  const [optionTab, setOptionTab] = useState("default");
107
  const [availableContactsToAdd, setAvailableContactsToAdd] = useState([]);
104
  const [availableContactsToAdd, setAvailableContactsToAdd] = useState([]);
108
  const [groupContactsList, setGroupContactsList] = useState([]);
105
  const [groupContactsList, setGroupContactsList] = useState([]);
109
  const [confirmModalShow, setConfirmModalShow] = useState(false);
-
 
110
  const [optionsLoading, setOptionsLoading] = useState(false);
106
  const [confirmModalShow, setConfirmModalShow] = useState(false);
111
  const [showEmojiTab, setShowEmojiTab] = useState(false);
107
  const [showEmojiTab, setShowEmojiTab] = useState(false);
Línea 112... Línea 108...
112
  const [shareFileModalShow, setShareFileModalShow] = useState(false);
108
  const [shareFileModalShow, setShareFileModalShow] = useState(false);
113
 
109
 
Línea 180... Línea 176...
180
      setPages(resData.data.pages);
176
      setPages(resData.data.pages);
181
      scrollToBottom();
177
      scrollToBottom();
182
    } else {
178
    } else {
183
      setMessages([...updatedMessages]);
179
      setMessages([...updatedMessages]);
184
    }
180
    }
185
 
-
 
186
    setLoading(false);
-
 
187
  };
181
  };
Línea 188... Línea 182...
188
 
182
 
189
  const handleLoadMore = async () => {
183
  const handleLoadMore = async () => {
190
    await axios.get(`${url_get_all_messages}?page=${currentPage}`)
184
    await axios.get(`${url_get_all_messages}?page=${currentPage}`)
Línea 202... Línea 196...
202
 
196
 
203
  const handleCloseChat = () => {
197
  const handleCloseChat = () => {
204
    onClose(id, url_close);
198
    onClose(id, url_close);
Línea -... Línea 199...
-
 
199
  };
-
 
200
 
-
 
201
  useEffect(() => {
-
 
202
    if (document.activeElement === textAreaEl.current && not_seen_messages) {
-
 
203
      handleReadChat(index)
-
 
204
    }
205
  };
205
  }, [messages])
206
 
206
 
207
  const handleChatBoxKeyDown = async (e) => {
207
  const handleChatBoxKeyDown = async (e) => {
208
    if (e.key === "Enter") {
208
    if (e.key === "Enter") {
209
      e.preventDefault();
209
      e.preventDefault();
Línea 438... Línea 438...
438
        break;
438
        break;
439
    }
439
    }
440
  }, [optionTab]);
440
  }, [optionTab]);
Línea 441... Línea 441...
441
 
441
 
442
  const loadPersonsAvailable = async () => {
-
 
443
    setOptionsLoading(true);
442
  const loadPersonsAvailable = async () => {
444
    await axios.get(url_get_contacts_availables_for_group).then((response) => {
443
    await axios.get(url_get_contacts_availables_for_group).then((response) => {
445
      const resData = response.data;
444
      const resData = response.data;
446
      if (resData.success) {
445
      if (resData.success) {
447
        setAvailableContactsToAdd(resData.data);
446
        setAvailableContactsToAdd(resData.data);
448
      }
447
      }
449
    });
-
 
450
    setOptionsLoading(false);
448
    });
Línea 451... Línea 449...
451
  };
449
  };
452
 
-
 
453
  const loadGroupContacts = async () => {
450
 
454
    setOptionsLoading(true);
451
  const loadGroupContacts = async () => {
455
    await axios.get(url_get_contact_group_list).then((response) => {
452
    await axios.get(url_get_contact_group_list).then((response) => {
456
      const resData = response.data;
453
      const resData = response.data;
457
      if (resData.success) {
454
      if (resData.success) {
458
        setGroupContactsList(resData.data);
455
        setGroupContactsList(resData.data);
459
      }
-
 
460
    });
456
      }
Línea 461... Línea 457...
461
    setOptionsLoading(false);
457
    });
462
  };
458
  };
463
 
459
 
Línea 648... Línea 644...
648
            {/* <small className="status"'+ status+'></small> */}
644
            {/* <small className="status"'+ status+'></small> */}
649
          </div>
645
          </div>
650
        </div>
646
        </div>
651
        <div className="panel personal-chat">
647
        <div className="panel personal-chat">
652
          <StyledChatHead>
648
          <StyledChatHead>
653
            <div
-
 
654
              className={`panel-heading chatboxhead ${unsee_messages ? "notify" : ""
649
            <div className={`panel-heading chatboxhead ${not_seen_messages ? "notify" : ""}`}>
655
                }`}
-
 
656
            >
-
 
657
              <div className="panel-title">
650
              <div className="panel-title">
658
                <img
651
                <img
659
                  className="chat-image img-circle pull-left"
652
                  className="chat-image img-circle pull-left"
660
                  height="36"
653
                  height="36"
661
                  width="36"
654
                  width="36"
Línea 839... Línea 832...
839
          </div>
832
          </div>
840
        </div>
833
        </div>
841
        <div className="panel personal-chat">
834
        <div className="panel personal-chat">
842
          <StyledChatHead>
835
          <StyledChatHead>
843
            <div
836
            <div
844
              className={`panel-heading chatboxhead ${unsee_messages ? "notify" : ""
837
              className={`panel-heading chatboxhead ${not_seen_messages ? "notify" : ""
845
                }`}
838
                }`}
846
            >
839
            >
847
              <div className="panel-title-group">
840
              <div className="panel-title-group">
848
                <img
841
                <img
849
                  className="chat-image img-circle pull-left"
842
                  className="chat-image img-circle pull-left"