Web: Files: SharingPanel: fix crash

This commit is contained in:
Viktor Fomin 2022-05-17 15:49:41 +03:00
parent ddb1cb4dd9
commit 2c723c704a

View File

@ -351,15 +351,16 @@ class SharingPanelComponent extends React.Component {
? shareDataItems.find((x) => x.sharedTo.shareLink)?.access
: null;
this.setState({
baseShareData,
shareDataItems,
accessOptions,
externalAccessOptions,
//showPanel: true,
filesOwnerId,
baseExternalAccess,
});
this._isMounted &&
this.setState({
baseShareData,
shareDataItems,
accessOptions,
externalAccessOptions,
//showPanel: true,
filesOwnerId,
baseExternalAccess,
});
})
.catch((err) => {
@ -368,9 +369,10 @@ class SharingPanelComponent extends React.Component {
})
.finally(() => {
setTimeout(() => {
return this.setState({
isLoading: false,
});
if (this._isMounted)
return this.setState({
isLoading: false,
});
}, 500);
});
};
@ -419,11 +421,15 @@ class SharingPanelComponent extends React.Component {
componentDidMount() {
this.getShareData();
this._isMounted = true;
document.addEventListener("keyup", this.onKeyPress);
window.addEventListener("popstate", () => this.onClose());
}
componentWillUnmount() {
this._isMounted = false;
document.removeEventListener("keyup", this.onKeyPress);
window.removeEventListener("popstate", () => this.onClose());
}
onKeyPress = (event) => {