Skip to content

Commit

Permalink
12.0 fix selected dirents number bug (#6296)
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael18811380328 authored Jul 4, 2024
1 parent 1eb7090 commit 8b016da
Showing 1 changed file with 6 additions and 18 deletions.
24 changes: 6 additions & 18 deletions frontend/src/pages/lib-content-view/lib-content-view.js
Original file line number Diff line number Diff line change
Expand Up @@ -1527,10 +1527,7 @@ class LibContentView extends React.Component {
let direntList = this.state.direntList.filter(item => {
return item.name !== name;
});

// Recalculate the state of the selection
this.recaculateSelectedStateAfterDirentDeleted(name, direntList);

this.recalculateSelectedDirents([name], direntList);
this.setState({direntList: direntList});
} else if (Utils.isAncestorPath(direntPath, this.state.path)) {
// the deleted item is ancester of the current item
Expand All @@ -1545,10 +1542,7 @@ class LibContentView extends React.Component {
let direntList = this.state.direntList.filter(item => {
return direntNames.indexOf(item.name) === -1;
});

// Recalculate the state of the selection
this.recaculateSelectedStateAfterDirentDeleted(name, direntList);

this.recalculateSelectedDirents(direntNames, direntList);
this.setState({direntList: direntList});
};

Expand All @@ -1561,10 +1555,7 @@ class LibContentView extends React.Component {
let direntList = this.state.direntList.filter(item => {
return item.name !== name;
});

// Recalculate the state of the selection
this.recaculateSelectedStateAfterDirentDeleted(name, direntList);

this.recalculateSelectedDirents([name], direntList);
this.setState({direntList: direntList});
};

Expand All @@ -1573,10 +1564,7 @@ class LibContentView extends React.Component {
let direntList = this.state.direntList.filter(item => {
return direntNames.indexOf(item.name) === -1;
});

// Recalculate the state of the selection
//this.recaculateSelectedStateAfterDirentDeleted(name, direntList);

this.recalculateSelectedDirents(direntNames, direntList);
this.setState({
direntList: direntList,
selectedDirentList: [],
Expand Down Expand Up @@ -1847,11 +1835,11 @@ class LibContentView extends React.Component {
});
};

recaculateSelectedStateAfterDirentDeleted = (name, newDirentList) => {
recalculateSelectedDirents = (unSelectNames, newDirentList) => {
let selectedDirentList = this.state.selectedDirentList.slice(0);
if (selectedDirentList.length > 0) {
selectedDirentList = selectedDirentList.filter(item => {
return item.name !== name;
return !unSelectNames.includes(item.name);
});
}
this.setState({
Expand Down

0 comments on commit 8b016da

Please sign in to comment.