diff --git a/frontend/src/components/dirent-detail/dirent-details.js b/frontend/src/components/dirent-detail/dirent-details.js index 1c51ddb210..d9959d8afb 100644 --- a/frontend/src/components/dirent-detail/dirent-details.js +++ b/frontend/src/components/dirent-detail/dirent-details.js @@ -50,7 +50,9 @@ class DirentDetail extends React.Component { componentWillReceiveProps(nextProps) { let { dirent, path, repoID } = nextProps; - this.loadDirentInfo(dirent, path, repoID); + if (this.props.dirent !== nextProps.dirent) { + this.loadDirentInfo(dirent, path, repoID); + } if (this.props.direntDetailPanelTab) { this.tabItemClick(this.props.direntDetailPanelTab); } diff --git a/frontend/src/view-file-text.js b/frontend/src/view-file-text.js index d1e60122a3..27ceafafdb 100644 --- a/frontend/src/view-file-text.js +++ b/frontend/src/view-file-text.js @@ -89,8 +89,8 @@ class ViewFileText extends React.Component { } addParticipant = () => { - seafileAPI.addFileParticipant(repoID, filePath, username).then((res) => { - if (res.status === 201) { + seafileAPI.addFileParticipants(repoID, filePath, [username]).then((res) => { + if (res.status === 200) { this.isParticipant = true; this.getParticipants(); } @@ -100,11 +100,12 @@ class ViewFileText extends React.Component { getParticipants = () => { seafileAPI.listFileParticipants(repoID, filePath).then((res) => { const participants = res.data.participant_list; - if (participants.length === 0) return; this.setState({ participants: participants }); - this.isParticipant = participants.every((participant) => { - return participant.email == username; - }); + if (participants.length > 0) { + this.isParticipant = participants.every((participant) => { + return participant.email == username; + }); + } }); }