Skip to content

Commit e9b39f2

Browse files
committed
factor out other method
1 parent 4498a73 commit e9b39f2

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

packages/core/src/shared/settings.ts

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -632,9 +632,7 @@ export class ToolkitPromptSettings
632632
}
633633

634634
public async disablePrompt(promptName: toolkitPromptName): Promise<void> {
635-
if (this.isPromptEnabled(promptName)) {
636-
await this.update(promptName, true)
637-
}
635+
return await disablePrompt(this, promptName)
638636
}
639637

640638
static #instance: ToolkitPromptSettings
@@ -658,9 +656,7 @@ export class AmazonQPromptSettings
658656
}
659657

660658
public async disablePrompt(promptName: amazonQPromptName): Promise<void> {
661-
if (this.isPromptEnabled(promptName)) {
662-
await this.update(promptName, true)
663-
}
659+
return await disablePrompt(this, promptName)
664660
}
665661

666662
static #instance: AmazonQPromptSettings
@@ -954,3 +950,12 @@ function isPromptEnabled<
954950
return true
955951
}
956952
}
953+
954+
async function disablePrompt<
955+
S extends { update(key: P & string, value: boolean): Promise<boolean> } & PromptSettings,
956+
P extends AllPromptNames,
957+
>(settings: S, promptName: P) {
958+
if (settings.isPromptEnabled(promptName)) {
959+
await settings.update(promptName, true)
960+
}
961+
}

0 commit comments

Comments
 (0)