Skip to content

Commit

Permalink
Don't reveal on multiple Get/Refresh (ing-bank#47)
Browse files Browse the repository at this point in the history
  • Loading branch information
atiplea committed Nov 18, 2018
1 parent 6157465 commit 440bc1f
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions src/hostCommands/refresh.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,29 +9,29 @@ const icon = utils.icons.REFRESH;
export async function refreshElementHandler(context: utils.ExtensionCommandContext): Promise<void> {
let c = utils.getFullContext(context);
if (c.mode === utils.ContextMode.FILE) {
return refreshElement(c.fsPath).catch(() => {});
return refreshElement(c.fsPath, true).catch();
}
else if (c.mode === utils.ContextMode.DIRECTORY) {
let files = await vscode.window.showOpenDialog({defaultUri: vscode.Uri.file(c.fsPath), canSelectMany: true, openLabel: 'Refresh'})
let files = await vscode.window.showOpenDialog({ defaultUri: vscode.Uri.file(c.fsPath), canSelectMany: true, openLabel: 'Refresh' })
if (!files) return;
for (let fsPath of files.map(file => file.fsPath)) {
await refreshElement(fsPath).catch(() => {});
await refreshElement(fsPath, false).catch();
}
}
else {
let quickPick = await environment.workspaceQuickPick();
if (!quickPick) return;
let chosenEnv = quickPick;
let files = await vscode.window.showOpenDialog({defaultUri: vscode.Uri.file(chosenEnv.fsPath), canSelectMany: true, openLabel: 'Refresh'})
let files = await vscode.window.showOpenDialog({ defaultUri: vscode.Uri.file(chosenEnv.fsPath), canSelectMany: true, openLabel: 'Refresh' })
if (!files) return;
for (let fsPath of files.map(file => file.fsPath)) {
await refreshElement(fsPath).catch(() => {})
await refreshElement(fsPath, false).catch();
}
}
return;
}

async function refreshElement(fsPath: string) {
async function refreshElement(fsPath: string, showTextDocument: boolean) {
if (!fs.statSync(fsPath).isFile()) return;
let env;
return utils.executeWithProgress(`${icon} ${path.basename(fsPath)} REFRESH`, async () => {
Expand All @@ -58,7 +58,7 @@ async function refreshElement(fsPath: string) {
await fs.writeFile(fsPath, output);
utils.logger.info(`${utils.icons.SUCCESS} ${icon} ${path.basename(fsPath)} REFRESH from ${env.name} succeeded`);
connection.close();
await vscode.window.showTextDocument(doc);
if (showTextDocument) await vscode.window.showTextDocument(doc);
}).catch((e: Error) => {
if (env && env.name) {
utils.logger.error(`${utils.icons.ERROR} ${icon} error in ${env.name} ${e.message}`);
Expand All @@ -83,7 +83,7 @@ export async function refreshTableHandler(context: utils.ExtensionCommandContext
return;
}
let targetDir = path.dirname(c.fsPath);
return refreshTable(tableName, targetDir).catch(() => {});
return refreshTable(tableName, targetDir).catch(() => { });
}
}

Expand Down Expand Up @@ -118,4 +118,4 @@ async function refreshTable(tableName: string, targetDirectory: string) {
utils.logger.error(`${utils.icons.ERROR} ${icon} ${e.message}`);
}
})
}
}

0 comments on commit 440bc1f

Please sign in to comment.