@@ -95,51 +95,51 @@ const CommentView = ({ classroomName }) => {
95
95
endpoint : "/courses/" + courseId + "/posts/" + post . _id + "/comments" ,
96
96
onSuccess : ( data ) => {
97
97
setCommentData ( [ ...renderComments ( data , userRole ) ] ) ;
98
- io . emit ( "join" , { room : post . _id , room_type : "post" } ) ;
98
+ // io.emit("join", { room: post._id, room_type: "post" });
99
99
} ,
100
100
} ) ;
101
101
}
102
102
// io.emit("join", { room: post._id, room_type: "post" });
103
103
if ( post ) {
104
104
return ( ) => {
105
- io . emit ( "leave" , { room : post . _id } ) ;
105
+ // io.emit("leave", { room: post._id });
106
106
} ;
107
107
}
108
108
} , [ post ] ) ;
109
109
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]);
143
143
144
144
const draftNewComment = ( ) => {
145
145
setNewComments ( {
0 commit comments