diff --git a/frontend/src/components/file-chooser/file-chooser.js b/frontend/src/components/file-chooser/file-chooser.js index 33ed33bcb5..28213524e7 100644 --- a/frontend/src/components/file-chooser/file-chooser.js +++ b/frontend/src/components/file-chooser/file-chooser.js @@ -110,9 +110,9 @@ class FileChooser extends React.Component { } } - onCurrentRepoToggle = () => [ - this.setState({isCurrentRepoShow: !this.state.isCurrentRepoShow}) - ] + onCurrentRepoToggle = () => { + this.setState({isCurrentRepoShow: !this.state.isCurrentRepoShow}); + } onDirentItemClick = (repo, filePath, dirent) => { this.props.onDirentItemClick(repo, filePath, dirent); @@ -310,7 +310,7 @@ class FileChooser extends React.Component { selectedItemInfo: selectedItemInfo }); - if (item.repo_id === this.props.repoID) { + if (this.props.repoID && item.repo_id === this.props.repoID) { seafileAPI.getRepoInfo(this.props.repoID).then(res => { // need to optimized let repoInfo = new RepoInfo(res.data); diff --git a/frontend/src/components/file-chooser/tree-list-item.js b/frontend/src/components/file-chooser/tree-list-item.js index bc5ccc1e9a..b3e201c53d 100644 --- a/frontend/src/components/file-chooser/tree-list-item.js +++ b/frontend/src/components/file-chooser/tree-list-item.js @@ -36,7 +36,11 @@ class TreeViewItem extends React.Component { onItemClick = (e) => { e.stopPropagation(); // need prevent event popup - let isCurrentRepo = this.props.selectedRepo.repo_id === this.props.repo.repo_id; + let isCurrentRepo = false; + if (this.props.selectedRepo) { + isCurrentRepo = this.props.selectedRepo.repo_id === this.props.repo.repo_id; + } + if (isCurrentRepo) { if (this.props.selectedPath !== this.state.filePath) { this.props.onDirentItemClick(this.state.filePath, this.props.node.object); @@ -77,7 +81,10 @@ class TreeViewItem extends React.Component { render() { let { node } = this.props; - let isCurrentRepo = this.props.selectedRepo.repo_id === this.props.repo.repo_id; + let isCurrentRepo = false; + if (this.props.selectedRepo) { + isCurrentRepo = this.props.selectedRepo.repo_id === this.props.repo.repo_id; + } let isCurrentPath = this.props.selectedPath === this.state.filePath; const fileName = node.object.name;