content: String,
parent_id: Option<i32>,
post_id: i32,
+ form_id: Option<String>, // An optional form id, so you know which message came back
auth: String
}
}
data: {
content: String,
edit_id: i32,
+ form_id: Option<String>,
auth: String,
}
}
content: String,
parent_id: Option<i32>,
pub post_id: i32,
+ form_id: Option<String>,
auth: String,
}
pub struct EditComment {
content: String,
edit_id: i32,
+ form_id: Option<String>,
auth: String,
}
pub struct CommentResponse {
pub comment: CommentView,
pub recipient_ids: Vec<i32>,
+ pub form_id: Option<String>,
}
#[derive(Serialize, Deserialize)]
let mut res = CommentResponse {
comment: comment_view,
recipient_ids,
+ form_id: data.form_id.to_owned(),
};
if let Some(ws) = websocket_info {
let mut res = CommentResponse {
comment: comment_view,
recipient_ids,
+ form_id: data.form_id.to_owned(),
};
if let Some(ws) = websocket_info {
let mut res = CommentResponse {
comment: comment_view,
recipient_ids,
+ form_id: None,
};
if let Some(ws) = websocket_info {
let mut res = CommentResponse {
comment: comment_view,
recipient_ids,
+ form_id: None,
};
if let Some(ws) = websocket_info {
let res = CommentResponse {
comment: comment_view,
recipient_ids: Vec::new(),
+ form_id: None,
};
Ok(res)
Ok(CommentResponse {
comment: comment_view,
recipient_ids: Vec::new(),
+ form_id: None,
})
}
}
let mut res = CommentResponse {
comment: liked_comment,
recipient_ids,
+ form_id: None,
};
if let Some(ws) = websocket_info {
let res = CommentResponse {
comment: comment_view,
recipient_ids,
+ form_id: None,
};
chat_server.do_send(SendComment {
let res = CommentResponse {
comment: comment_view,
recipient_ids,
+ form_id: None,
};
chat_server.do_send(SendComment {
let res = CommentResponse {
comment: comment_view,
recipient_ids,
+ form_id: None,
};
chat_server.do_send(SendComment {
let res = CommentResponse {
comment: comment_view,
recipient_ids,
+ form_id: None,
};
chat_server.do_send(SendComment {
let res = CommentResponse {
comment: comment_view,
recipient_ids,
+ form_id: None,
};
chat_server.do_send(SendComment {
let res = CommentResponse {
comment: comment_view,
recipient_ids,
+ form_id: None,
};
chat_server.do_send(SendComment {
let res = CommentResponse {
comment: comment_view,
recipient_ids,
+ form_id: None,
};
chat_server.do_send(SendComment {
let res = CommentResponse {
comment: comment_view,
recipient_ids,
+ form_id: None,
};
chat_server.do_send(SendComment {
let res = CommentResponse {
comment: comment_view,
recipient_ids,
+ form_id: None,
};
chat_server.do_send(SendComment {
);
}
- handleFinished(op: UserOperation, data: CommentResponse) {
- let isReply =
- this.props.node !== undefined && data.comment.parent_id !== null;
- let xor =
- +!(data.comment.parent_id !== null) ^ +(this.props.node !== undefined);
-
- if (
- (data.comment.creator_id == UserService.Instance.user.id &&
- ((op == UserOperation.CreateComment &&
- // If its a reply, make sure parent child match
- isReply &&
- data.comment.parent_id == this.props.node.comment.id) ||
- // Otherwise, check the XOR of the two
- (!isReply && xor))) ||
- // If its a comment edit, only check that its from your user, and that its a
- // text edit only
-
- (data.comment.creator_id == UserService.Instance.user.id &&
- op == UserOperation.EditComment &&
- data.comment.content)
- ) {
- this.state.finished = true;
- this.setState(this.state);
- }
- }
-
- handleCommentSubmit(val: string) {
- this.state.commentForm.content = val;
+ handleCommentSubmit(msg: { val: string; formId: string }) {
+ this.state.commentForm.content = msg.val;
+ this.state.commentForm.form_id = msg.formId;
if (this.props.edit) {
WebSocketService.Instance.editComment(this.state.commentForm);
} else {
// Only do the showing and hiding if logged in
if (UserService.Instance.user) {
- if (res.op == UserOperation.CreateComment) {
- let data = res.data as CommentResponse;
- this.handleFinished(res.op, data);
- } else if (res.op == UserOperation.EditComment) {
+ if (
+ res.op == UserOperation.CreateComment ||
+ res.op == UserOperation.EditComment
+ ) {
let data = res.data as CommentResponse;
- this.handleFinished(res.op, data);
+
+ // This only finishes this form, if the randomly generated form_id matches the one received
+ if (this.state.commentForm.form_id == data.form_id) {
+ this.setState({ finished: true });
+ }
}
}
}
replyType?: boolean;
focus?: boolean;
disabled?: boolean;
- onSubmit?(val: string): any;
+ onSubmit?(msg: { val: string; formId: string }): any;
onContentChange?(val: string): any;
onReplyCancel?(): any;
}
event.preventDefault();
i.state.loading = true;
i.setState(i.state);
- i.props.onSubmit(i.state.content);
+ let msg = { val: i.state.content, formId: i.formId };
+ i.props.onSubmit(msg);
}
handleReplyCancel(i: MarkdownTextArea) {
parent_id?: number;
edit_id?: number;
creator_id?: number;
+ form_id?: string;
auth: string;
}
export interface CommentResponse {
comment: Comment;
recipient_ids: Array<number>;
+ form_id?: string;
}
export interface CommentLikeForm {