1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-07 18:03:48 +00:00

12.0 fix selected dirents number bug (#6296)

This commit is contained in:
Michael An
2024-07-04 16:54:39 +08:00
committed by GitHub
parent 1eb709023e
commit 8b016dabb2

View File

@@ -1527,10 +1527,7 @@ class LibContentView extends React.Component {
let direntList = this.state.direntList.filter(item => { let direntList = this.state.direntList.filter(item => {
return item.name !== name; return item.name !== name;
}); });
this.recalculateSelectedDirents([name], direntList);
// Recalculate the state of the selection
this.recaculateSelectedStateAfterDirentDeleted(name, direntList);
this.setState({direntList: direntList}); this.setState({direntList: direntList});
} else if (Utils.isAncestorPath(direntPath, this.state.path)) { } else if (Utils.isAncestorPath(direntPath, this.state.path)) {
// the deleted item is ancester of the current item // the deleted item is ancester of the current item
@@ -1545,10 +1542,7 @@ class LibContentView extends React.Component {
let direntList = this.state.direntList.filter(item => { let direntList = this.state.direntList.filter(item => {
return direntNames.indexOf(item.name) === -1; return direntNames.indexOf(item.name) === -1;
}); });
this.recalculateSelectedDirents(direntNames, direntList);
// Recalculate the state of the selection
this.recaculateSelectedStateAfterDirentDeleted(name, direntList);
this.setState({direntList: direntList}); this.setState({direntList: direntList});
}; };
@@ -1561,10 +1555,7 @@ class LibContentView extends React.Component {
let direntList = this.state.direntList.filter(item => { let direntList = this.state.direntList.filter(item => {
return item.name !== name; return item.name !== name;
}); });
this.recalculateSelectedDirents([name], direntList);
// Recalculate the state of the selection
this.recaculateSelectedStateAfterDirentDeleted(name, direntList);
this.setState({direntList: direntList}); this.setState({direntList: direntList});
}; };
@@ -1573,10 +1564,7 @@ class LibContentView extends React.Component {
let direntList = this.state.direntList.filter(item => { let direntList = this.state.direntList.filter(item => {
return direntNames.indexOf(item.name) === -1; return direntNames.indexOf(item.name) === -1;
}); });
this.recalculateSelectedDirents(direntNames, direntList);
// Recalculate the state of the selection
//this.recaculateSelectedStateAfterDirentDeleted(name, direntList);
this.setState({ this.setState({
direntList: direntList, direntList: direntList,
selectedDirentList: [], selectedDirentList: [],
@@ -1847,11 +1835,11 @@ class LibContentView extends React.Component {
}); });
}; };
recaculateSelectedStateAfterDirentDeleted = (name, newDirentList) => { recalculateSelectedDirents = (unSelectNames, newDirentList) => {
let selectedDirentList = this.state.selectedDirentList.slice(0); let selectedDirentList = this.state.selectedDirentList.slice(0);
if (selectedDirentList.length > 0) { if (selectedDirentList.length > 0) {
selectedDirentList = selectedDirentList.filter(item => { selectedDirentList = selectedDirentList.filter(item => {
return item.name !== name; return !unSelectNames.includes(item.name);
}); });
} }
this.setState({ this.setState({