diff --git a/frontend/src/components/dirent-detail/detail-container.js b/frontend/src/components/dirent-detail/detail-container.js index 31630a4f9a..85b4c01654 100644 --- a/frontend/src/components/dirent-detail/detail-container.js +++ b/frontend/src/components/dirent-detail/detail-container.js @@ -20,7 +20,10 @@ const DetailContainer = React.memo(({ repoID, path, dirent, currentRepoInfo, rep if (path === '/' && !dirent) { return ( - + ); } return ( @@ -36,7 +39,8 @@ const DetailContainer = React.memo(({ repoID, path, dirent, currentRepoInfo, rep /> ); }, (props, nextProps) => { - const isChanged = props.repoID !== nextProps.repoID || + const isChanged = + props.repoID !== nextProps.repoID || props.path !== nextProps.path || !ObjectUtils.isSameObject(props.dirent, nextProps.dirent) || !ObjectUtils.isSameObject(props.currentRepoInfo, nextProps.currentRepoInfo) || diff --git a/frontend/src/components/share-link-panel/link-list.js b/frontend/src/components/share-link-panel/link-list.js index 61d2e9a88b..090a5e0ae2 100644 --- a/frontend/src/components/share-link-panel/link-list.js +++ b/frontend/src/components/share-link-panel/link-list.js @@ -73,7 +73,7 @@ class LinkList extends React.Component { {shareLinks.length == 0 ? ( - + ) : (
diff --git a/frontend/src/pages/lib-content-view/lib-content-view.js b/frontend/src/pages/lib-content-view/lib-content-view.js index abf07dad0d..c7cc9dff26 100644 --- a/frontend/src/pages/lib-content-view/lib-content-view.js +++ b/frontend/src/pages/lib-content-view/lib-content-view.js @@ -567,26 +567,24 @@ class LibContentView extends React.Component { }; loadDirentList = (path) => { + const { repoID } = this.props; + const { sortBy, sortOrder } = this.state; this.setState({ isDirentListLoading: true, direntList: [], }); - let repoID = this.props.repoID; seafileAPI.listDir(repoID, path, { 'with_thumbnail': true }).then(res => { - let direntList = []; - res.data.dirent_list.forEach(item => { - let dirent = new Dirent(item); - direntList.push(dirent); - }); - + const { dirent_list, user_perm: userPerm, dir_id: dirID } = res.data; + const direntList = Utils.sortDirents(dirent_list.map(item => new Dirent(item)), sortBy, sortOrder); this.setState({ pathExist: true, - userPerm: res.data.user_perm, + userPerm, isDirentListLoading: false, - direntList: Utils.sortDirents(direntList, this.state.sortBy, this.state.sortOrder), - dirID: res.data.dir_id, - path: path, + direntList, + dirID, + path, isSessionExpired: false, + currentDirent: null, }); if (this.state.currentRepoInfo.is_admin) { @@ -633,8 +631,7 @@ class LibContentView extends React.Component { }; onListContainerScroll = () => { - let itemsShowLength = this.state.itemsShowLength + 100; - this.setState({ itemsShowLength: itemsShowLength }); + this.setState({ itemsShowLength: this.state.itemsShowLength + 100 }); }; resetShowLength = () => { @@ -2018,19 +2015,11 @@ class LibContentView extends React.Component { }; getSelectedDirentPaths = () => { - let paths = []; - this.state.selectedDirentList.forEach(selectedDirent => { - paths.push(Utils.joinPath(this.state.path, selectedDirent.name)); - }); - return paths; + return this.state.selectedDirentList.map(selectedDirent => Utils.joinPath(this.state.path, selectedDirent.name)); }; getSelectedDirentNames = () => { - let names = []; - this.state.selectedDirentList.forEach(selectedDirent => { - names.push(selectedDirent.name); - }); - return names; + return this.state.selectedDirentList.map(selectedDirent => selectedDirent.name); }; resetSelected = () => {