mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2024-11-25 15:06:55 +00:00
Fix subscription leak (#465)
* Fix subscription leak * Update src/Explorer/SplashScreen/SplashScreen.tsx Co-authored-by: Laurent Nguyen <laurent.nguyen@microsoft.com> * Array needs to exist in the first place Co-authored-by: Laurent Nguyen <laurent.nguyen@microsoft.com>
This commit is contained in:
parent
7188e8d8c2
commit
d314a20b81
@ -41,19 +41,32 @@ export class SplashScreen extends React.Component<SplashScreenProps> {
|
|||||||
private static readonly failoverUrl = "https://docs.microsoft.com/azure/cosmos-db/high-availability";
|
private static readonly failoverUrl = "https://docs.microsoft.com/azure/cosmos-db/high-availability";
|
||||||
|
|
||||||
private readonly container: Explorer;
|
private readonly container: Explorer;
|
||||||
|
private subscriptions: Array<{ dispose: () => void }>;
|
||||||
|
|
||||||
constructor(props: SplashScreenProps) {
|
constructor(props: SplashScreenProps) {
|
||||||
super(props);
|
super(props);
|
||||||
this.container = props.explorer;
|
this.container = props.explorer;
|
||||||
this.container.tabsManager.openedTabs.subscribe(() => this.setState({}));
|
this.subscriptions = [];
|
||||||
this.container.selectedNode.subscribe(() => this.setState({}));
|
|
||||||
this.container.isNotebookEnabled.subscribe(() => this.setState({}));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public shouldComponentUpdate() {
|
public shouldComponentUpdate() {
|
||||||
return this.container.tabsManager.openedTabs.length === 0;
|
return this.container.tabsManager.openedTabs.length === 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public componentWillUnmount() {
|
||||||
|
while (this.subscriptions.length) {
|
||||||
|
this.subscriptions.pop().dispose();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public componentDidMount() {
|
||||||
|
this.subscriptions.push(
|
||||||
|
this.container.tabsManager.openedTabs.subscribe(() => this.setState({})),
|
||||||
|
this.container.selectedNode.subscribe(() => this.setState({})),
|
||||||
|
this.container.isNotebookEnabled.subscribe(() => this.setState({}))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
private clearMostRecent = (): void => {
|
private clearMostRecent = (): void => {
|
||||||
MostRecentActivity.mostRecentActivity.clear(userContext.databaseAccount?.id);
|
MostRecentActivity.mostRecentActivity.clear(userContext.databaseAccount?.id);
|
||||||
this.setState({});
|
this.setState({});
|
||||||
|
Loading…
Reference in New Issue
Block a user