Skip to content

Commit

Permalink
core fix cancelAllDialogs
Browse files Browse the repository at this point in the history
  • Loading branch information
matus-sabo committed Sep 26, 2019
1 parent 22cd670 commit c30c844
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions packages/botkit/src/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -777,14 +777,14 @@ export class Botkit {
public async saveState(bot: BotWorker, force = false): Promise<void> {
try {
const context = bot.getConfig('context');
const dialogContext = bot.getConfig('dialogContext');

if (force) {
if (force || dialogContext.stack.length === 0) {
await this.conversationState.saveChanges(context);
return;
}

const activity = bot.getConfig('activity');
const dialogContext = bot.getConfig('dialogContext');

const turnContextAfter = new TurnContext(this.adapter, activity);
const dialogContextAfter = await this.dialogSet.createContext(turnContextAfter);
Expand All @@ -795,7 +795,6 @@ export class Botkit {
instanceIdAfter = dialogContextAfter.stack[0].state.values.instanceId;
}

// @ts-ignore
let instanceIdBefore = dialogContext.stack[0].state.values.instanceId;
if (instanceIdBefore !== instanceIdAfter) {
await this.conversationState.saveChanges(context);
Expand Down

0 comments on commit c30c844

Please sign in to comment.