Proyectos de Subversion LeadersLinked - Backend

Rev

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

Rev 14574 Rev 14576
Línea 8... Línea 8...
8
 
8
 
Línea 9... Línea 9...
9
const notifyAudio = new Audio('/audio/chat.mp3')
9
const notifyAudio = new Audio('/audio/chat.mp3')
10
 
10
 
11
const Chat = (props) => {
-
 
12
	// states
11
const Chat = (props) => {
13
	const [fullChats, setFullChats] = useState([])
12
	// states
14
	const [contacts, setContacts] = useState([])
13
	const [contacts, setContacts] = useState([])
15
	const [groups, setGroups] = useState([])
14
	const [groups, setGroups] = useState([])
16
	const [activeChats, setActiveChats] = useState([])
15
	const [activeChats, setActiveChats] = useState([])
Línea 22... Línea 21...
22
 
21
 
23
	const filtredContacts = contacts.filter(({ name }) => name.toLowerCase().includes(search.toLowerCase()))
22
	const filtredContacts = contacts.filter(({ name }) => name.toLowerCase().includes(search.toLowerCase()))
Línea 24... Línea 23...
24
	const filtredGroups = groups.filter(({ name }) => name.toLowerCase().includes(search.toLowerCase()))
23
	const filtredGroups = groups.filter(({ name }) => name.toLowerCase().includes(search.toLowerCase()))
25
 
-
 
26
	const handleEntities = entities => {
24
 
27
		setFullChats([...entities])
25
	const handleEntities = entities => {
28
		let newUserContacts = []
26
		let newUserContacts = []
29
		let newGroups = []
27
		let newGroups = []
30
		entities.map((entity) => {
28
		entities.map((entity) => {
Línea 90... Línea 88...
90
			}
88
			}
91
		}
89
		}
92
	}
90
	}
Línea 93... Línea 91...
93
 
91
 
94
	const handleNewMessage = async (unseeEntity) => {
92
	const handleNewMessage = async (unseeEntity) => {
95
		await axios.post(unseeEntity.url_mark_received).then((response) => {
-
 
96
			('')
-
 
97
		})
93
		await axios.post(unseeEntity.url_mark_received)
98
		if (!activeChats.some((activeChat) => activeChat.id === unseeEntity.id)) {
94
		if (!activeChats.some((activeChat) => activeChat.id === unseeEntity.id)) {
99
			setActiveChats([...activeChats, { ...unseeEntity, minimized: false }])
95
			setActiveChats([...activeChats, { ...unseeEntity, minimized: false }])
100
			playNotifyAudio()
96
			playNotifyAudio()
101
		} else {
97
		} else {
Línea 115... Línea 111...
115
		if (activeChats.length < 3 && !activeChats.some((el) => el.id === entity.id)) {
111
		if (activeChats.length < 3 && !activeChats.some((el) => el.id === entity.id)) {
116
			setActiveChats([...activeChats, { ...entity, minimized: minimized }])
112
			setActiveChats([...activeChats, { ...entity, minimized: minimized }])
117
		}
113
		}
118
		if (activeChats.length >= 3 && !activeChats.some((el) => el.id === entity.id)) {
114
		if (activeChats.length >= 3 && !activeChats.some((el) => el.id === entity.id)) {
119
			activeChats.map((el, index) => {
115
			activeChats.map((el, index) => {
120
				if (index === 0) {
-
 
121
					axios.post(el.url_close)
116
				if (index === 0) axios.post(el.url_close)
122
				}
-
 
123
			})
117
			})
124
			const newActiveChats = activeChats.filter((el, index) => index !== 0)
118
			const newActiveChats = activeChats.filter((el, index) => index !== 0)
125
			setActiveChats([...newActiveChats, { ...entity, minimized: minimized }])
119
			setActiveChats([...newActiveChats, { ...entity, minimized: minimized }])
126
		}
120
		}
127
	}
121
	}
Línea 159... Línea 153...
159
	}
153
	}
Línea 160... Línea 154...
160
 
154
 
161
	const handleCloseChat = (entityId, url_close) => {
155
	const handleCloseChat = (entityId, url_close) => {
162
		let newActiveChats = []
156
		let newActiveChats = []
163
		setLoading(true)
157
		setLoading(true)
164
		axios.post(url_close).then((response) => {
-
 
165
			const resData = response.data
-
 
166
		})
158
		axios.post(url_close)
167
		newActiveChats = activeChats.filter(
159
		newActiveChats = activeChats.filter(
168
			(activeChat) => activeChat.id !== entityId
160
			(activeChat) => activeChat.id !== entityId
169
		)
161
		)
170
		setActiveChats(newActiveChats)
162
		setActiveChats(newActiveChats)