From 554db41e6aa0e7f286d3200ebd0520f0c59bf19e Mon Sep 17 00:00:00 2001 From: Joel Mut Date: Tue, 5 Mar 2024 17:12:25 -0300 Subject: [PATCH] Move SaveAllChanges method from SetProperty to OAuthInput --- .../Actions/SetProperties.cs | 3 --- .../Actions/SetProperty.cs | 3 --- .../Microsoft.Bot.Builder.Dialogs.Adaptive/Input/OAuthInput.cs | 3 ++- 3 files changed, 2 insertions(+), 7 deletions(-) diff --git a/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Actions/SetProperties.cs b/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Actions/SetProperties.cs index 2cd129f458..d0e0840569 100644 --- a/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Actions/SetProperties.cs +++ b/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Actions/SetProperties.cs @@ -85,9 +85,6 @@ public SetProperties([CallerFilePath] string callerPath = "", [CallerLineNumber] dc.State.SetValue(propValue.Property.GetValue(dc.State), value); } - // save all state scopes to their respective botState locations. - await dc.Context.TurnState.Get().SaveAllChangesAsync(cancellationToken).ConfigureAwait(false); - return await dc.EndDialogAsync(cancellationToken: cancellationToken).ConfigureAwait(false); } diff --git a/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Actions/SetProperty.cs b/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Actions/SetProperty.cs index 420e19a1af..38b07230c0 100644 --- a/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Actions/SetProperty.cs +++ b/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Actions/SetProperty.cs @@ -89,9 +89,6 @@ public SetProperty([CallerFilePath] string callerPath = "", [CallerLineNumber] i dc.State.SetValue(this.Property.GetValue(dc.State), value); - // save all state scopes to their respective botState locations. - await dc.Context.TurnState.Get().SaveAllChangesAsync(cancellationToken).ConfigureAwait(false); - return await dc.EndDialogAsync(cancellationToken: cancellationToken).ConfigureAwait(false); } diff --git a/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Input/OAuthInput.cs b/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Input/OAuthInput.cs index 8938d14be9..318447cabe 100644 --- a/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Input/OAuthInput.cs +++ b/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Input/OAuthInput.cs @@ -8,6 +8,7 @@ using System.Threading.Tasks; using AdaptiveExpressions.Properties; using Microsoft.Bot.Builder.Dialogs.Adaptive.Conditions; +using Microsoft.Bot.Builder.Dialogs.Memory; using Microsoft.Bot.Schema; using Newtonsoft.Json; @@ -312,7 +313,7 @@ private async Task SendOAuthCardAsync(DialogContext dc, IMessageActivity prompt, // Save state prior to sending OAuthCard: the invoke response for a token exchange from the root bot could come in // before this method ends or could land in another instance in scale-out scenarios, which means that if the state is not saved, // the OAuthInput would not be at the top of the stack, and the token exchange invoke would get discarded. - await dc.Context.TurnState.Get().SaveChangesAsync(dc.Context, false, cancellationToken).ConfigureAwait(false); + await dc.Context.TurnState.Get().SaveAllChangesAsync(cancellationToken).ConfigureAwait(false); // Prepare OAuthCard var title = Title == null ? null : await Title.GetValueAsync(dc, cancellationToken).ConfigureAwait(false);