Improve Azure startup time and fix command palette (#5761)

* Improve Azure startup time and fix command palette
- Improvement (but not full fix) for #4732 where Azure startup is very slow.
This speeds the startup by up to 5 seconds by
  - Changing from fixed 5 second initial wait time to a promise to check for accounts
  - Using the accounts changed notification to send a message when accounts are ready. This is usually what will "win out" since Azure seems to load before the Account Providers are set up.
- Remove right-click actions from the command palette.
- Rename Azure actions so it's clear what they are in the command palette.

* Remove coveralls task while investigating how to make optional task

* Add void return type
This commit is contained in:
Kevin Cunnane
2019-05-31 10:22:01 -07:00
committed by GitHub
parent a364af5c4c
commit ae0603c041
6 changed files with 85 additions and 59 deletions

View File

@@ -8,7 +8,6 @@ import * as fs from 'fs';
import * as path from 'path';
import * as os from 'os';
import * as constants from './constants';
import * as azdata from 'azdata';
import { AppContext } from './appContext';
import { ApiWrapper } from './apiWrapper';
@@ -30,7 +29,6 @@ import { registerAzureResourceCommands } from './azureResource/commands';
import { registerAzureResourceDatabaseServerCommands } from './azureResource/providers/databaseServer/commands';
import { registerAzureResourceDatabaseCommands } from './azureResource/providers/database/commands';
import { AzureResourceTreeProvider } from './azureResource/tree/treeProvider';
import { equals } from './azureResource/utils';
let extensionContext: vscode.ExtensionContext;
@@ -72,7 +70,6 @@ export function activate(context: vscode.ExtensionContext) {
registerAzureServices(appContext);
const azureResourceTree = new AzureResourceTreeProvider(appContext);
pushDisposable(apiWrapper.registerTreeDataProvider('azureResourceExplorer', azureResourceTree));
registerAccountService(appContext, azureResourceTree);
registerCommands(appContext, azureResourceTree);
return {
@@ -113,26 +110,12 @@ async function initAzureAccountProvider(extensionContext: vscode.ExtensionContex
function registerAzureServices(appContext: AppContext): void {
appContext.registerService<AzureResourceService>(AzureResourceServiceNames.resourceService, new AzureResourceService());
appContext.registerService<IAzureResourceAccountService>(AzureResourceServiceNames.accountService, new AzureResourceAccountService(appContext.apiWrapper));
appContext.registerService<IAzureResourceCacheService>(AzureResourceServiceNames.cacheService, new AzureResourceCacheService(extensionContext));
appContext.registerService<IAzureResourceSubscriptionService>(AzureResourceServiceNames.subscriptionService, new AzureResourceSubscriptionService());
appContext.registerService<IAzureResourceSubscriptionFilterService>(AzureResourceServiceNames.subscriptionFilterService, new AzureResourceSubscriptionFilterService(new AzureResourceCacheService(extensionContext)));
appContext.registerService<IAzureResourceTenantService>(AzureResourceServiceNames.tenantService, new AzureResourceTenantService());
}
function registerAccountService(appContext: AppContext, azureResourceTree: AzureResourceTreeProvider): void {
let accountService = new AzureResourceAccountService(appContext.apiWrapper);
appContext.registerService<IAzureResourceAccountService>(AzureResourceServiceNames.accountService, accountService);
let previousAccounts: Array<azdata.Account> = undefined;
accountService.onDidChangeAccounts((e: azdata.DidChangeAccountsParams) => {
// the onDidChangeAccounts event will trigger in many cases where the accounts didn't actually change
// the notifyNodeChanged event triggers a refresh which triggers a getChildren which can trigger this callback
// this below check short-circuits the infinite callback loop
if (!equals(e.accounts, previousAccounts)) {
azureResourceTree.notifyNodeChanged(undefined);
}
previousAccounts = e.accounts;
});
}
function registerCommands(appContext: AppContext, azureResourceTree: AzureResourceTreeProvider): void {
registerAzureResourceCommands(appContext, azureResourceTree);