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