mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-10 19:29:56 +00:00
Add comment and participant (#3882)
* update handle error * comment and add participant * update nextProps
This commit is contained in:
@@ -28,6 +28,7 @@ class CommentPanel extends React.Component {
|
||||
showResolvedComment: true,
|
||||
participants: null,
|
||||
};
|
||||
this.isParticipant = false;
|
||||
}
|
||||
|
||||
toggleResolvedComment = () => {
|
||||
@@ -62,10 +63,22 @@ class CommentPanel extends React.Component {
|
||||
let errMessage = Utils.getErrorMsg(error);
|
||||
toaster.danger(errMessage);
|
||||
});
|
||||
this.addParticipant();
|
||||
}
|
||||
this.refs.commentTextarea.value = '';
|
||||
}
|
||||
|
||||
addParticipant = () => {
|
||||
if (this.isParticipant) return;
|
||||
seafileAPI.addFileParticipant(repoID, filePath, username).then((res) => {
|
||||
this.isParticipant = true;
|
||||
this.onParticipantsChange(repoID, filePath);
|
||||
}).catch((err) => {
|
||||
let errMessage = Utils.getErrorMsg(err);
|
||||
toaster.danger(errMessage);
|
||||
});
|
||||
}
|
||||
|
||||
resolveComment = (event) => {
|
||||
seafileAPI.updateComment(repoID, event.target.id, 'true').then(() => {
|
||||
this.listComments();
|
||||
@@ -103,10 +116,25 @@ class CommentPanel extends React.Component {
|
||||
|
||||
getParticipants = () => {
|
||||
if (this.props.participants) {
|
||||
this.setState({ participants: this.props.participants });
|
||||
this.setState({ participants: this.props.participants }, () => {
|
||||
this.checkParticipant();
|
||||
});
|
||||
} else {
|
||||
seafileAPI.listFileParticipants(repoID, filePath).then((res) => {
|
||||
this.setState({ participants: res.data.participant_list });
|
||||
this.setState({ participants: res.data.participant_list }, () => {
|
||||
this.checkParticipant();
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
checkParticipant = () => {
|
||||
const participants = this.state.participants;
|
||||
if (participants.length === 0) {
|
||||
this.isParticipant = false;
|
||||
} else {
|
||||
this.isParticipant = participants.some((participant) => {
|
||||
return participant.email === username;
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -120,6 +148,9 @@ class CommentPanel extends React.Component {
|
||||
if (this.props.commentsNumber !== nextProps.commentsNumber) {
|
||||
this.listComments();
|
||||
}
|
||||
if (this.props.participants !== nextProps.participants) {
|
||||
this.setState({ participants: nextProps.participants });
|
||||
}
|
||||
}
|
||||
|
||||
render() {
|
||||
|
Reference in New Issue
Block a user