diff --git a/src/Explorer/SplashScreen/SplashScreen.tsx b/src/Explorer/SplashScreen/SplashScreen.tsx index c6e55c7c7..5fa305b28 100644 --- a/src/Explorer/SplashScreen/SplashScreen.tsx +++ b/src/Explorer/SplashScreen/SplashScreen.tsx @@ -41,19 +41,32 @@ export class SplashScreen extends React.Component { private static readonly failoverUrl = "https://docs.microsoft.com/azure/cosmos-db/high-availability"; private readonly container: Explorer; + private subscriptions: Array<{ dispose: () => void }>; constructor(props: SplashScreenProps) { super(props); this.container = props.explorer; - this.container.tabsManager.openedTabs.subscribe(() => this.setState({})); - this.container.selectedNode.subscribe(() => this.setState({})); - this.container.isNotebookEnabled.subscribe(() => this.setState({})); + this.subscriptions = []; } public shouldComponentUpdate() { 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 => { MostRecentActivity.mostRecentActivity.clear(userContext.databaseAccount?.id); this.setState({});