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:
@@ -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);
|
||||
|
Reference in New Issue
Block a user