Skip to content

Commit b371821

Browse files
committed
commented all of client socketio references
1 parent 4bf1533 commit b371821

File tree

3 files changed

+62
-62
lines changed

3 files changed

+62
-62
lines changed

client/src/components/comments/CommentView.js

+35-35
Original file line numberDiff line numberDiff line change
@@ -95,51 +95,51 @@ const CommentView = ({ classroomName }) => {
9595
endpoint: "/courses/" + courseId + "/posts/" + post._id + "/comments",
9696
onSuccess: (data) => {
9797
setCommentData([...renderComments(data, userRole)]);
98-
io.emit("join", { room: post._id, room_type: "post" });
98+
// io.emit("join", { room: post._id, room_type: "post" });
9999
},
100100
});
101101
}
102102
// io.emit("join", { room: post._id, room_type: "post" });
103103
if (post) {
104104
return () => {
105-
io.emit("leave", { room: post._id });
105+
// io.emit("leave", { room: post._id });
106106
};
107107
}
108108
}, [post]);
109109

110-
useEffect(() => {
111-
io.on("Comment/create", (comment) => {
112-
//console.log(comment);
113-
// Ensure the user isn't the one who posted it
114-
if (
115-
comment &&
116-
comment.postedBy._id !== user._id &&
117-
comment.postedBy._id !== user.anonymousId
118-
) {
119-
// console.log(commentData);
120-
setCommentData([
121-
...commentData,
122-
<Comment comment={comment} key={comment._id} />,
123-
]);
124-
}
125-
});
126-
io.on("Reply/create", (comment) => {
127-
// console.log(comment, "ws");
128-
// Take copy of socketComments and append reply to matching comment (with _id)
129-
// console.log(commentData);
130-
let allComments = [...commentData];
131-
// console.log(allComments);
132-
for (let i in allComments) {
133-
// console.log(allComments[i], "in for loop");
134-
if (allComments[i].props.comment._id === comment._id) {
135-
// console.log("found a match");
136-
allComments[i] = <Comment comment={comment} key={comment._id} />;
137-
break;
138-
}
139-
}
140-
setCommentData(allComments);
141-
});
142-
}, [commentData]);
110+
// useEffect(() => {
111+
// io.on("Comment/create", (comment) => {
112+
// //console.log(comment);
113+
// // Ensure the user isn't the one who posted it
114+
// if (
115+
// comment &&
116+
// comment.postedBy._id !== user._id &&
117+
// comment.postedBy._id !== user.anonymousId
118+
// ) {
119+
// // console.log(commentData);
120+
// setCommentData([
121+
// ...commentData,
122+
// <Comment comment={comment} key={comment._id} />,
123+
// ]);
124+
// }
125+
// });
126+
// io.on("Reply/create", (comment) => {
127+
// // console.log(comment, "ws");
128+
// // Take copy of socketComments and append reply to matching comment (with _id)
129+
// // console.log(commentData);
130+
// let allComments = [...commentData];
131+
// // console.log(allComments);
132+
// for (let i in allComments) {
133+
// // console.log(allComments[i], "in for loop");
134+
// if (allComments[i].props.comment._id === comment._id) {
135+
// // console.log("found a match");
136+
// allComments[i] = <Comment comment={comment} key={comment._id} />;
137+
// break;
138+
// }
139+
// }
140+
// setCommentData(allComments);
141+
// });
142+
// }, [commentData]);
143143

144144
const draftNewComment = () => {
145145
setNewComments({

client/src/components/posts/PostFeed.js

+19-19
Original file line numberDiff line numberDiff line change
@@ -106,25 +106,25 @@ const PostFeed = ({
106106
const [displayMobileOptionsPanel, setDisplayMobileOptionsPanel] =
107107
useState(false);
108108

109-
useEffect(() => {
110-
io.emit("join", { room: courseId, room_type: "course" });
111-
// io.on("Post/create", (post) => {
112-
// // Ensure the user isn't the one who posted it
113-
// console.log("[SOCKETIO] Post/create: post - ", post);
114-
// if (
115-
// post &&
116-
// post.postedBy._id !== user._id &&
117-
// post.postedBy._id !== user.anonymousId
118-
// ) {
119-
// console.log("[PostFeed] socketPosts: ", [post, ...socketPosts]);
120-
// setSocketPosts([post, ...socketPosts]);
121-
// }
122-
// });
123-
124-
return () => {
125-
io.emit("leave", { room: courseId });
126-
};
127-
}, []);
109+
// useEffect(() => {
110+
// io.emit("join", { room: courseId, room_type: "course" });
111+
// // io.on("Post/create", (post) => {
112+
// // // Ensure the user isn't the one who posted it
113+
// // console.log("[SOCKETIO] Post/create: post - ", post);
114+
// // if (
115+
// // post &&
116+
// // post.postedBy._id !== user._id &&
117+
// // post.postedBy._id !== user.anonymousId
118+
// // ) {
119+
// // console.log("[PostFeed] socketPosts: ", [post, ...socketPosts]);
120+
// // setSocketPosts([post, ...socketPosts]);
121+
// // }
122+
// // });
123+
124+
// return () => {
125+
// io.emit("leave", { room: courseId });
126+
// };
127+
// }, []);
128128

129129
const [isCondensed, setCondensedState] = useState(false || width <= 540);
130130

client/src/services/socketio.js

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
import socketIOClient from "socket.io-client";
1+
// import socketIOClient from "socket.io-client";
22
// Controls reconnect attempts
33
// const io = socketIOClient(process.env.REACT_APP_SERVER_URL, {
44
// withCredentials: true,
55
// reconnectionAttempts: 1,
66
// });
77

8-
let path = process.env.REACT_APP_SOCKETIO_PATH;
8+
// let path = process.env.REACT_APP_SOCKETIO_PATH;
99

10-
const io = socketIOClient(process.env.REACT_APP_SERVER_URL, {
11-
path: path,
12-
withCredentials: true,
13-
reconnectionAttempts: 1,
14-
});
10+
// const io = socketIOClient(process.env.REACT_APP_SERVER_URL, {
11+
// path: path,
12+
// withCredentials: true,
13+
// reconnectionAttempts: 1,
14+
// });
1515

16-
export default io;
16+
// export default io;

0 commit comments

Comments
 (0)