Skip to content

Commit 04a5b68

Browse files
authored
refactor(settings): non-async isPromptEnabled() #6255
## Problem There is no real reason this needs to be async. It is also now inconsistent with `isExperimentEnabled`. ## Solution Make non-async and add logged error if the promise rejects.
1 parent b085dd9 commit 04a5b68

File tree

16 files changed

+24
-24
lines changed

16 files changed

+24
-24
lines changed

packages/core/src/auth/sso/ssoAccessTokenProvider.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -808,7 +808,7 @@ class DiskCacheErrorMessage {
808808
: ToolkitPromptSettings.instance
809809

810810
// We know 'ssoCacheError' is in all extension prompt settings
811-
if (await promptSettings.isPromptEnabled('ssoCacheError')) {
811+
if (promptSettings.isPromptEnabled('ssoCacheError')) {
812812
const result = await showMessage()
813813
if (result === dontShow) {
814814
await promptSettings.disablePrompt('ssoCacheError')

packages/core/src/awsService/apprunner/commands/pauseService.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export async function pauseService(node: AppRunnerServiceNode): Promise<void> {
1818

1919
try {
2020
const prompts = ToolkitPromptSettings.instance
21-
const shouldNotify = await prompts.isPromptEnabled('apprunnerNotifyPause')
21+
const shouldNotify = prompts.isPromptEnabled('apprunnerNotifyPause')
2222
const notifyPrompt = localize(
2323
'aws.apprunner.pauseService.notify',
2424
'Your service will be unavailable while paused. ' +

packages/core/src/awsService/apprunner/wizards/deploymentButton.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ function makeDeployButtons() {
3232
async function showDeploymentCostNotification(): Promise<void> {
3333
const settings = ToolkitPromptSettings.instance
3434

35-
if (await settings.isPromptEnabled('apprunnerNotifyPricing')) {
35+
if (settings.isPromptEnabled('apprunnerNotifyPricing')) {
3636
const notice = localize(
3737
'aws.apprunner.createService.priceNotice.message',
3838
'App Runner automatic deployments incur an additional cost.'

packages/core/src/awsService/ecs/commands.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ async function runCommandWizard(
3232

3333
const wizard = new CommandWizard(
3434
container,
35-
await ToolkitPromptSettings.instance.isPromptEnabled('ecsRunCommand'),
35+
ToolkitPromptSettings.instance.isPromptEnabled('ecsRunCommand'),
3636
command
3737
)
3838
const response = await wizard.run()
@@ -75,7 +75,7 @@ export async function toggleExecuteCommandFlag(
7575
'Disabling command execution will change the state of resources in your AWS account, including but not limited to stopping and restarting the service.\n Continue?'
7676
)
7777

78-
if (await settings.isPromptEnabled(prompt)) {
78+
if (settings.isPromptEnabled(prompt)) {
7979
const choice = await window.showWarningMessage(warningMessage, yes, yesDontAskAgain, no)
8080
if (choice === undefined || choice === no) {
8181
throw new CancellationError('user')

packages/core/src/awsService/s3/fileViewerManager.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ export class S3FileViewerManager {
346346
}
347347

348348
private async showEditNotification(): Promise<void> {
349-
if (!(await this.settings.isPromptEnabled(promptOnEditKey))) {
349+
if (!this.settings.isPromptEnabled(promptOnEditKey)) {
350350
return
351351
}
352352

packages/core/src/codecatalyst/activation.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ export async function activate(ctx: ExtContext): Promise<void> {
128128
await showReadmeFileOnFirstLoad(ctx.extensionContext.workspaceState)
129129

130130
const settings = ToolkitPromptSettings.instance
131-
if (await settings.isPromptEnabled('remoteConnected')) {
131+
if (settings.isPromptEnabled('remoteConnected')) {
132132
const message = localize(
133133
'AWS.codecatalyst.connectedMessage',
134134
'Welcome to your Amazon CodeCatalyst Dev Environment. For more options and information, view Dev Environment settings ({0} Extension > CodeCatalyst).',

packages/core/src/codewhisperer/commands/gettingStartedPageCommands.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export class CodeWhispererCommandBackend {
2020

2121
const prompts = AmazonQPromptSettings.instance
2222
// To check the condition If the user has already seen the welcome message
23-
if (!(await prompts.isPromptEnabled('codeWhispererNewWelcomeMessage'))) {
23+
if (!prompts.isPromptEnabled('codeWhispererNewWelcomeMessage')) {
2424
telemetry.ui_click.emit({ elementId: 'codewhisperer_Learn_ButtonClick', passive: true })
2525
}
2626
return showCodeWhispererWebview(this.extContext, source)

packages/core/src/codewhisperer/util/authUtil.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ export class AuthUtil {
366366
public async notifySessionConfiguration() {
367367
const suppressId = 'amazonQSessionConfigurationMessage'
368368
const settings = AmazonQPromptSettings.instance
369-
const shouldShow = await settings.isPromptEnabled(suppressId)
369+
const shouldShow = settings.isPromptEnabled(suppressId)
370370
if (!shouldShow) {
371371
return
372372
}

packages/core/src/codewhisperer/vue/backend.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ export async function showCodeWhispererWebview(
161161
]
162162
const prompts = AmazonQPromptSettings.instance
163163
// To check the condition If the user has already seen the welcome message
164-
if (await prompts.isPromptEnabled('codeWhispererNewWelcomeMessage')) {
164+
if (prompts.isPromptEnabled('codeWhispererNewWelcomeMessage')) {
165165
telemetry.ui_click.emit({ elementId: 'codewhisperer_Learn_PageOpen', passive: true })
166166
} else {
167167
telemetry.ui_click.emit({ elementId: 'codewhisperer_Learn_PageOpen', passive: false })

packages/core/src/shared/awsContextCommands.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ export class AwsContextCommands {
6565
await this.editCredentials()
6666
if (
6767
credentialsFiles.length === 0 &&
68-
(await ToolkitPromptSettings.instance.isPromptEnabled('createCredentialsProfile')) &&
68+
ToolkitPromptSettings.instance.isPromptEnabled('createCredentialsProfile') &&
6969
(await this.promptCredentialsSetup())
7070
) {
7171
await this.onCommandCreateCredentialsProfile()

0 commit comments

Comments
 (0)