serg1557733 1 year ago
parent
commit
af455d9bf8

+ 0 - 1
frontend/src/components/chatPage/generalChat/FindUserBox.jsx

@@ -10,7 +10,6 @@ export const FindUserBox = () => {
     const [findUser, setfindUser] = useState('');
     const [showUsers, setShowUsers] = useState(false)
     const res = allUsers.filter(user =>  user.userName.toLowerCase().includes(findUser.toLowerCase()))
- 
     return (
         <>
             <div className='online'>  

+ 1 - 1
frontend/src/components/chatPage/generalChat/UserInfoButton.jsx

@@ -26,7 +26,7 @@ export const UserInfoButton = ({item, i}) => {
 
     const [isPrivate, setIsPrivate] = useState(false)
 
-    console.log('usersinfobutton Item',item)
+  //  console.log('usersinfobutton Item',item)
 
     useEffect(() => {
         if(newPrivateMessages.text && newPrivateMessages?.sender[0].userName === item.userName){

+ 4 - 3
frontend/src/components/chatPage/privateChat/PrivateChat.jsx

@@ -11,6 +11,7 @@ import useSound from 'use-sound';
 import { PrivatChatHeader } from './PrivatChatHeader';
 import { privateMessage } from '../../../reducers/userDataReducer';
 import notifSound from '../../../assets/get.mp3'
+import {isNewPrivateMessages} from "../../../reducers/dataReducers";
 import { UserInfoButton } from '../generalChat/UserInfoButton';
 
 //need to fix update wenn message sendet and icon for new private messages
@@ -33,9 +34,9 @@ export const PrivateChat = () => {
 
     let endMessages = useRef(null);
 
-socket.on('send privat messages', (messages)=> {
-    setStartMessages(messages)
-  });
+    socket.on('send privat messages', (messages)=> {
+        setStartMessages(messages)
+    });
   
 // bug need to fix****************
 

+ 8 - 3
frontend/src/components/chatPage/userInfo/UserInfo.jsx

@@ -4,7 +4,7 @@ import { useSelector } from 'react-redux';
 import './userInfo.scss';
 import { useDispatch } from 'react-redux';
 import { getUserAvatar } from '../../../reducers/userDataReducer';
-import { useState, useEffect } from 'react';
+import { useState, useCallback } from 'react';
 import { UserInfoButton } from '../generalChat/UserInfoButton';
 import { AdminUserInfiButton } from '../generalChat/AdminUserInfiButton';
 import { MainChatButtton } from '../generalChat/MainChatButtton';
@@ -51,12 +51,15 @@ export const UserInfo = () => {
         setDisplayType('none')
     }
 
+console.log(user)
+
     // if(socket){
     //     socket.on('my chats', (data)=> console.log('my chats', data))
     // }
 
-    console.log(usersOnline)
+console.log(usersOnline)
         
+
     return (
             <>  
                 <h4 style={{color:'white'}}> Hello, {user.userName} </h4>
@@ -90,13 +93,14 @@ export const UserInfo = () => {
                    
                 <MainChatButtton/>     
 
-                <FindUserBox/>        
+                <FindUserBox/>     
                 
                     { user.isAdmin && !isTabletorMobile ? 
                             allUsers.map((item, i) =>
                             (user.userName !== item?.userName) 
                                 && <AdminUserInfiButton item={item} i={i} key={i}/>) 
                         :
+
                             usersOnline.map((item, i) =>
                                     (user.userName !== item.userName && !friendsIds.includes(item._id) ) && <UserInfoButton item = {item} i = {i}  key={i} />                   
                             )
@@ -114,6 +118,7 @@ export const UserInfo = () => {
                 </div>
 
             
+
             </>
         )
 }