Fix BDC tree getting stuck loading (#20116)

This commit is contained in:
Charles Gagnon
2022-07-20 12:50:11 -07:00
committed by GitHub
parent 2d9720962a
commit ada1588bb7

View File

@@ -42,12 +42,11 @@ export class ControllerTreeDataProvider implements vscode.TreeDataProvider<TreeN
} }
if (!this.initialized) { if (!this.initialized) {
this.loadSavedControllers().catch(err => { vscode.window.showErrorMessage(localize('bdc.controllerTreeDataProvider.error', "Unexpected error loading saved controllers: {0}", err)); }); try {
} else { await this.loadSavedControllers();
// We set the context here since VS Code takes a bit of time to process the _onDidChangeTreeData } catch (err) {
// and so if we set it as soon as we finished loading the controllers it would briefly flash void vscode.window.showErrorMessage(localize('bdc.controllerTreeDataProvider.error', "Unexpected error loading saved controllers: {0}", err));
// the "connect to controller" welcome view }
await vscode.commands.executeCommand('setContext', 'bdc.loaded', true);
} }
return this.root.getChildren(); return this.root.getChildren();
@@ -132,13 +131,12 @@ export class ControllerTreeDataProvider implements vscode.TreeDataProvider<TreeN
this.root.clearChildren(); this.root.clearChildren();
treeNodes.forEach(node => this.root.addChild(node)); treeNodes.forEach(node => this.root.addChild(node));
this.notifyNodeChanged(); await vscode.commands.executeCommand('setContext', 'bdc.loaded', true);
} catch (err) { } catch (err) {
// Reset so we can try again if the tree refreshes // Reset so we can try again if the tree refreshes
this.initialized = false; this.initialized = false;
throw err; throw err;
} }
} }
public async saveControllers(): Promise<void> { public async saveControllers(): Promise<void> {