Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update App.js #12

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions front-end/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ function App() {
};

useEffect(() => {
// se deben evitar los console.log en el client side
console.log(
"cambiooooo",
conversations,
Expand Down Expand Up @@ -134,6 +135,7 @@ function App() {
}, []);

useEffect(() => {
// se deben evitar los console.log en el client side
console.log("cambio user", user);
if (user && user._id && user.name) {
if (!socket) setSocket(new WebSocket(socketURL));
Expand Down Expand Up @@ -169,7 +171,8 @@ function App() {
useEffect(() => {
if (socket && user && user._id) {
socket.onopen = () => {
socket.send(JSON.stringify({ state: 4, message: user._id }));
socket.send(JSON.stringify({ state: 4, message: user._id }));
// se deben evitar los console.log en el client side
console.log("holu socket conectado");
socket.onerror = function (event) {
console.error("WebSocket error observed", event);
Expand Down Expand Up @@ -204,12 +207,15 @@ function App() {
if (data.receiverId) c["mySocketId"] = data.receiverId;
setChat(c);
} else {
// se deben evitar los console.log en el client side
console.log("socket not found ");
}
} else if (data.state === 1) {
} else if (data.state === 1) {
// se deben evitar los console.log en el client side
console.log("mesg 1", inMsg);
setHeader(data.message);
} else if (data.state === 2) {
// se deben evitar los console.log en el client side
console.log("mesg 2", inMsg);
const c = {
betterHalf: data.senderId,
Expand All @@ -219,9 +225,11 @@ function App() {
setChat(c);
} else if (data.state === 3) {
if (data.data) {
// se deben evitar los console.log en el client side
console.log("me llego nueva usersData", data.data);
setUsersData(data.data);
} else {
// se deben evitar los console.log en el client side
console.log("me llego solo estado 3", data);
}
} else if (data.state === 4) {
Expand Down Expand Up @@ -313,6 +321,7 @@ function App() {
[...new Set(d)]
)
);
// se deben evitar los console.log en el client side
console.log("mesg mandado", JSON.stringify(payload));
} else if (user && user._id) {
console.log("socket not found creating socket");
Expand Down