Skip to content

Commit

Permalink
Fix getting templates when offline and clean up getting templates (#373)
Browse files Browse the repository at this point in the history
  • Loading branch information
nturinski authored and ejizba committed May 15, 2018
1 parent b07f725 commit 5eb4973
Show file tree
Hide file tree
Showing 6 changed files with 169 additions and 180 deletions.
2 changes: 2 additions & 0 deletions src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ export const projectRuntimeSetting: string = 'projectRuntime';
export const templateFilterSetting: string = 'templateFilter';
export const deploySubpathSetting: string = 'deploySubpath';
export const templateVersionSetting: string = 'templateVersion';
export const v1ReleaseVersion: string = '1.0.12'; // known stable version
export const betaReleaseVersion: string = '2.0.1-beta.25'; // known stable version

export enum ProjectLanguage {
Bash = 'Bash',
Expand Down
11 changes: 4 additions & 7 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,13 @@ import { restartFunctionApp } from './commands/restartFunctionApp';
import { startFunctionApp } from './commands/startFunctionApp';
import { stopFunctionApp } from './commands/stopFunctionApp';
import { ext } from './extensionVariables';
import { getTemplateDataFromBackup, tryGetLatestTemplateData, tryGetTemplateDataFromCache } from './templates/TemplateData';
import { getTemplateData } from './templates/TemplateData';
import { FunctionAppProvider } from './tree/FunctionAppProvider';
import { FunctionAppTreeItem } from './tree/FunctionAppTreeItem';
import { FunctionTreeItem } from './tree/FunctionTreeItem';
import { ProxyTreeItem } from './tree/ProxyTreeItem';
import { dotnetUtils } from './utils/dotnetUtils';
import { functionRuntimeUtils } from './utils/functionRuntimeUtils';
import { cliFeedJsonResponse, getCliFeedJson } from './utils/getCliFeedJson';

export function activate(context: vscode.ExtensionContext): void {
let reporter: TelemetryReporter | undefined;
Expand Down Expand Up @@ -83,7 +82,7 @@ export function activate(context: vscode.ExtensionContext): void {
await validateFunctionProjects(this, ui, outputChannel, event.added);
});

const templateDataTask: Promise<void> = getTemplateData(reporter, context);
const templateDataTask: Promise<void> = getTemplateDataTask(context);

actionHandler.registerCommand('azureFunctions.selectSubscriptions', () => vscode.commands.executeCommand('azure-account.selectSubscriptions'));
actionHandler.registerCommand('azureFunctions.refresh', async (node?: IAzureNode) => await tree.refresh(node));
Expand Down Expand Up @@ -125,10 +124,8 @@ export function activate(context: vscode.ExtensionContext): void {
});
}

async function getTemplateData(reporter: TelemetryReporter | undefined, context: vscode.ExtensionContext): Promise<void> {
const cliFeedJson: cliFeedJsonResponse = await getCliFeedJson();
// tslint:disable-next-line:strict-boolean-expressions
ext.templateData = await tryGetTemplateDataFromCache(reporter, context.globalState, cliFeedJson) || await tryGetLatestTemplateData(reporter, cliFeedJson, context.globalState) || await getTemplateDataFromBackup(reporter, cliFeedJson);
async function getTemplateDataTask(context: vscode.ExtensionContext): Promise<void> {
ext.templateData = await getTemplateData(context.globalState);
}

// tslint:disable-next-line:no-empty
Expand Down
Loading

0 comments on commit 5eb4973

Please sign in to comment.