Skip to content

Commit

Permalink
Updated to onTurn.
Browse files Browse the repository at this point in the history
  • Loading branch information
cmayomsft committed Jun 1, 2018
1 parent a8bb629 commit 46c3b56
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 17 deletions.
2 changes: 1 addition & 1 deletion samples/alarmbot-ts/src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ const alarmBot = new ServiceBot<BotConversationState, BotUserState>();
alarmBot.onTurn(async context => {

return new RootTopic(context)
.onReceiveActivity(context);
.onTurn(context);
});
12 changes: 6 additions & 6 deletions samples/alarmbot-ts/src/topics/addAlarmTopic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export class AddAlarmTopic extends ConversationTopic<StateContext<BotConversatio

this.state.alarm.title = value;

return this.onReceiveActivity(context);
return this.onTurn(context);
})
.onFailure(async (context, reason) => {
this.clearActiveTopic();
Expand All @@ -54,7 +54,7 @@ export class AddAlarmTopic extends ConversationTopic<StateContext<BotConversatio

this.state.alarm.time = value;

return this.onReceiveActivity(context);
return this.onTurn(context);
})
.onFailure(async (context, reason) => {
this.clearActiveTopic();
Expand All @@ -68,20 +68,20 @@ export class AddAlarmTopic extends ConversationTopic<StateContext<BotConversatio
);
};

public onReceiveActivity(context: StateContext<BotConversationState, BotUserState>) {
public onTurn(context: StateContext<BotConversationState, BotUserState>) {

if(this.hasActiveTopic) {
return this.activeTopic!.onReceiveActivity(context);
return this.activeTopic!.onTurn(context);
}

if (!this.state.alarm.title) {
return this.setActiveTopic("titlePrompt")
.onReceiveActivity(context);
.onTurn(context);
}

if (!this.state.alarm.time) {
return this.setActiveTopic("timePrompt")
.onReceiveActivity(context);
.onTurn(context);
}

return this._onSuccess!(context, this.state.alarm);
Expand Down
12 changes: 6 additions & 6 deletions samples/alarmbot-ts/src/topics/deleteAlarmTopic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export class DeleteAlarmTopic extends ConversationTopic<StateContext<BotConversa

this.state.alarmIndex = value;

return this.onReceiveActivity(context);
return this.onTurn(context);
})
.onFailure((context, reason) => {
this.clearActiveTopic();
Expand Down Expand Up @@ -72,7 +72,7 @@ export class DeleteAlarmTopic extends ConversationTopic<StateContext<BotConversa

this.state.deleteConfirmed = value;

return this.onReceiveActivity(context);
return this.onTurn(context);
})
.onFailure((context, reason) => {
this.clearActiveTopic();
Expand All @@ -86,10 +86,10 @@ export class DeleteAlarmTopic extends ConversationTopic<StateContext<BotConversa
);
}

public onReceiveActivity(context: StateContext<BotConversationState, BotUserState>) {
public onTurn(context: StateContext<BotConversationState, BotUserState>) {

if(this.hasActiveTopic) {
return this.activeTopic!.onReceiveActivity(context);
return this.activeTopic!.onTurn(context);
}

// If there are no alarms to delete...
Expand All @@ -105,15 +105,15 @@ export class DeleteAlarmTopic extends ConversationTopic<StateContext<BotConversa
this.state.alarmIndex = 0;
} else {
return this.setActiveTopic("whichAlarmPrompt")
.onReceiveActivity(context);
.onTurn(context);
}
}

this.state.alarm!.title = this.state.alarms![this.state.alarmIndex].title;

if (this.state.deleteConfirmed === undefined) {
return this.setActiveTopic("confirmDeletePrompt")
.onReceiveActivity(context);
.onTurn(context);
}

return this._onSuccess!(context, { alarm: this.state.alarm!, alarmIndex: this.state.alarmIndex, deleteConfirmed: this.state.deleteConfirmed });
Expand Down
8 changes: 4 additions & 4 deletions samples/alarmbot-ts/src/topics/rootTopic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export class RootTopic
);
}

public onReceiveActivity(context: StateContext<BotConversationState, BotUserState>) {
public onTurn(context: StateContext<BotConversationState, BotUserState>) {

if (context.activity.type === 'message' && context.activity.text.length > 0) {

Expand All @@ -81,11 +81,11 @@ export class RootTopic

// Set the active topic and let the active topic handle this turn.
return this.setActiveTopic("addAlarmTopic")
.onReceiveActivity(context);
.onTurn(context);
} else if (/delete alarm/i.test(context.activity.text)) {

return this.setActiveTopic("deleteAlarmTopic", context.userState.alarms)
.onReceiveActivity(context);
.onTurn(context);
} else if (/help/i.test(context.activity.text)) {
this.clearActiveTopic();

Expand All @@ -94,7 +94,7 @@ export class RootTopic

// If there is an active topic, let it handle this turn.
if (this.hasActiveTopic) {
return this.activeTopic!.onReceiveActivity(context);
return this.activeTopic!.onTurn(context);
}

return this.showDefaultMessage(context);
Expand Down

0 comments on commit 46c3b56

Please sign in to comment.