Accounts: Enable notification for accounts change (#2432)

* Enable notification for accounts change

* Fixed bugs in extHostAccountManagement.test.ts

* Fixed as commented:
1. Removed AccountWithProviderHandle
2. Use a private dictionary _accounts in ExtHostAccountManagement to cache all accounts and corresponding provider handles.
3. getSecurityToken gets provider handle from _accounts for specified account.
4. Added / changed unit tests for getAllAccounts & getSecurityToken
This commit is contained in:
Vincent Feng
2018-09-07 08:23:28 +08:00
committed by GitHub
parent 197e1c651f
commit 005c28dd3a
6 changed files with 177 additions and 47 deletions

25
src/sql/sqlops.d.ts vendored
View File

@@ -1855,14 +1855,19 @@ declare module 'sqlops' {
* Gets all added accounts.
* @returns {Thenable<Account>} Promise to return the accounts
*/
export function getAllAccounts(): Thenable<AccountWithProviderHandle[]>;
export function getAllAccounts(): Thenable<Account[]>;
/**
* Generates a security token by asking the account's provider
* @param {Account} account Account to generate security token for
* @return {Thenable<{}>} Promise to return the security token
*/
export function getSecurityToken(account: AccountWithProviderHandle): Thenable<{}>;
export function getSecurityToken(account: Account): Thenable<{}>;
/**
* An [event](#Event) which fires when the accounts have changed.
*/
export const onDidChangeAccounts: vscode.Event<DidChangeAccountsParams>;
}
/**
@@ -1930,19 +1935,9 @@ declare module 'sqlops' {
isStale: boolean;
}
/**
* Represents an account with account provider's handle
*/
export interface AccountWithProviderHandle {
/**
* Account
*/
account: Account;
/**
* Account's provider handle
*/
providerHandle: number;
export interface DidChangeAccountsParams {
// Updated accounts
accounts: Account[];
}
// - ACCOUNT PROVIDER //////////////////////////////////////////////////