Refactor node loading logic for tree controllers (#8980)

* Refactor node loading logic for tree controllers

* Add comment
This commit is contained in:
Charles Gagnon
2020-01-28 17:12:15 -08:00
committed by GitHub
parent 32a89676f1
commit 5618799305
2 changed files with 39 additions and 25 deletions

View File

@@ -5,6 +5,7 @@
import * as vscode from 'vscode';
import * as azdata from 'azdata';
import * as nls from 'vscode-nls';
import { TreeNode } from './treeNode';
import { IControllerTreeChangeHandler } from './controllerTreeChangeHandler';
import { AddControllerNode } from './addControllerNode';
@@ -13,6 +14,8 @@ import { showErrorMessage } from '../utils';
import { LoadingControllerNode } from './loadingControllerNode';
import { AuthType } from '../constants';
const localize = nls.loadMessageBundle();
const CredentialNamespace = 'clusterControllerCredentials';
interface IControllerInfoSlim {
@@ -43,7 +46,9 @@ export class ControllerTreeDataProvider implements vscode.TreeDataProvider<TreeN
return this.root.getChildren();
}
await this.loadSavedControllers();
// Kick off loading the saved controllers but then immediately return the loading node so
// the user isn't left with an empty tree while we load the nodes
this.loadSavedControllers().catch(err => { vscode.window.showErrorMessage(localize('bdc.controllerTreeDataProvider.error', "Unexpected error loading saved controllers: {0}", err)); });
return [new LoadingControllerNode()];
}