Skip to content
This repository was archived by the owner on Apr 22, 2024. It is now read-only.

Commit fb62983

Browse files
committed
Suggestion for on-responded on prompts
On issue microsoft#3947, relying on the responded flag todecide whether to show the prompt interferes with logic that could be happening either a. Concurrently b. On some middleware c. As part of how we reached the prompt I believe the *intention* is to prevent sending a prompt twice to the user, using a symbol may be enough for that, without relying on global status
1 parent a5ae17e commit fb62983

File tree

1 file changed

+5
-1
lines changed
  • libraries/botbuilder-dialogs/src/prompts

1 file changed

+5
-1
lines changed

libraries/botbuilder-dialogs/src/prompts/prompt.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,12 +200,15 @@ export abstract class Prompt<T> extends Dialog {
200200
state.options = opt;
201201
state.state = {};
202202

203+
dc.context.turnState.set(this.hasPrompted, true)
203204
// Send initial prompt
204205
await this.onPrompt(dc.context, state.state, state.options, false);
205206

206207
return Dialog.EndOfTurn;
207208
}
208209

210+
protected hasPrompted = Symbol('hasPrompted')
211+
209212
/**
210213
* Called when a prompt dialog is the active dialog and the user replied with a new activity.
211214
* @param dc The [DialogContext](xref:botbuilder-dialogs.DialogContext) for the current turn of conversation.
@@ -257,7 +260,8 @@ export abstract class Prompt<T> extends Dialog {
257260
if (isValid) {
258261
return await dc.endDialog(recognized.value);
259262
} else {
260-
if (!dc.context.responded) {
263+
if (!dc.context.turnState.get(this.hasPrompted)) {
264+
dc.context.turnState.set(this.hasPrompted, true)
261265
await this.onPrompt(dc.context, state.state, state.options, true);
262266
}
263267

0 commit comments

Comments
 (0)