Skip to content

Commit

Permalink
Fix open folder error when select folder (#6899)
Browse files Browse the repository at this point in the history
* 01 fix code bug when select another folder

* 02 optimise codes

* 03 fix no share link style
  • Loading branch information
Michael18811380328 authored Oct 15, 2024
1 parent 2a5d27e commit 14108e2
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 26 deletions.
8 changes: 6 additions & 2 deletions frontend/src/components/dirent-detail/detail-container.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ const DetailContainer = React.memo(({ repoID, path, dirent, currentRepoInfo, rep

if (path === '/' && !dirent) {
return (
<LibDetail currentRepoInfo={currentRepoInfo} onClose={onClose} />
<LibDetail
currentRepoInfo={currentRepoInfo}
onClose={onClose}
/>
);
}
return (
Expand All @@ -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) ||
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/share-link-panel/link-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class LinkList extends React.Component {
</div>
</div>
{shareLinks.length == 0 ? (
<EmptyTip text={gettext('No share links')}/>
<EmptyTip text={gettext('No share links')} className='m-0' />
) : (
<div className='share-list-container share-link-list'>
<table className="table-place-header">
Expand Down
35 changes: 12 additions & 23 deletions frontend/src/pages/lib-content-view/lib-content-view.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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 = () => {
Expand Down Expand Up @@ -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 = () => {
Expand Down

0 comments on commit 14108e2

Please sign in to comment.