1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-01 15:09:14 +00:00

Repair toolbar operation state (#4375)

* repair toolbar operation state error bug

* add comment

* optimized code
This commit is contained in:
杨顺强
2019-12-25 10:16:09 +08:00
committed by Daniel Pan
parent 0cd689b971
commit 520f6d4639

View File

@@ -1270,7 +1270,11 @@ class LibContentView extends React.Component {
let direntList = this.state.direntList.filter(item => {
return item.name !== name;
});
this.setState({ direntList: direntList });
// Recalculate the state of the selection
this.recaculateSelectedStateAfterDirentDeleted(name, direntList);
this.setState({direntList: direntList});
this.updateReadmeMarkdown(direntList);
} else if (Utils.isAncestorPath(direntPath, this.state.path)) {
// the deleted item is ancester of the current item
@@ -1289,6 +1293,10 @@ 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.setState({direntList: direntList});
this.updateReadmeMarkdown(direntList);
}
@@ -1537,6 +1545,20 @@ class LibContentView extends React.Component {
});
}
recaculateSelectedStateAfterDirentDeleted = (name, newDirentList) => {
let selectedDirentList = this.state.selectedDirentList.slice(0);
if (selectedDirentList.length > 0) {
selectedDirentList = selectedDirentList.filter(item => {
return item.name !== name;
});
}
this.setState({
selectedDirentList: selectedDirentList,
isDirentSelected: selectedDirentList.length > 0,
isAllDirentSelected: selectedDirentList.length === newDirentList.length,
});
}
onLibDecryptDialog = () => {
this.setState({libNeedDecrypt: false});
this.loadDirData(this.state.path);