Skip to content

Commit

Permalink
Move SaveAllChanges method from SetProperty to OAuthInput
Browse files Browse the repository at this point in the history
  • Loading branch information
sw-joelmut committed Mar 5, 2024
1 parent a4fc943 commit 554db41
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<DialogStateManager>().SaveAllChangesAsync(cancellationToken).ConfigureAwait(false);

return await dc.EndDialogAsync(cancellationToken: cancellationToken).ConfigureAwait(false);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<DialogStateManager>().SaveAllChangesAsync(cancellationToken).ConfigureAwait(false);

return await dc.EndDialogAsync(cancellationToken: cancellationToken).ConfigureAwait(false);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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<ConversationState>().SaveChangesAsync(dc.Context, false, cancellationToken).ConfigureAwait(false);
await dc.Context.TurnState.Get<DialogStateManager>().SaveAllChangesAsync(cancellationToken).ConfigureAwait(false);

// Prepare OAuthCard
var title = Title == null ? null : await Title.GetValueAsync(dc, cancellationToken).ConfigureAwait(false);
Expand Down

0 comments on commit 554db41

Please sign in to comment.