Skip to content

Commit 6c1ea4d

Browse files
committed
added auto-close dialog-await after 15s
1 parent b9ac8f3 commit 6c1ea4d

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

www/scripts/sepiaFW.assistant.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ function sepiaFW_build_assistant(){
55
//some global settings
66
Assistant.name = "Sepia"; //this should be received from server to prevent confusion with Usernames
77
Assistant.id = ""; //this should be received from server because it works as receiver for action-commands (buttons etc.)
8+
9+
//control settings
10+
Assistant.autoCloseAwaitDialog = true;
11+
Assistant.autoCloseAwaitDialogDelay = 15000; //15s
12+
var autoCloseAwaitDialogTimer;
813

914
//set assistant info received from server
1015
Assistant.updateInfo = function(id, name){
@@ -72,6 +77,8 @@ function sepiaFW_build_assistant(){
7277
}
7378
}
7479
function broadcastDialogTimeout(){
80+
//EXAMPLE:
81+
SepiaFW.animate.assistant.idle('dialogTimeout');
7582
}
7683

7784
//set direct command
@@ -108,6 +115,13 @@ function sepiaFW_build_assistant(){
108115
if (SepiaFW.account && (SepiaFW.account.getUserId() !== result.more.user)){
109116
return;
110117
}
118+
119+
//reset auto-close timer
120+
if (Assistant.autoCloseAwaitDialog){
121+
if (autoCloseAwaitDialogTimer){
122+
clearTimeout(autoCloseAwaitDialogTimer);
123+
}
124+
}
111125

112126
//handle mood
113127
if (result.more.mood){
@@ -161,6 +175,20 @@ function sepiaFW_build_assistant(){
161175
//broadcast
162176
Assistant.isWaitingForDialog = true;
163177
broadcastAwaitDialog();
178+
179+
//activate auto-close timer?
180+
if (Assistant.autoCloseAwaitDialog){
181+
autoCloseAwaitDialogTimer = setTimeout(function(){
182+
input_type = "question";
183+
input_miss = "";
184+
dialog_stage = 0;
185+
last_command = '';
186+
last_command_N = 0;
187+
//broadcast
188+
Assistant.isWaitingForDialog = false;
189+
broadcastDialogTimeout();
190+
}, Assistant.autoCloseAwaitDialogDelay);
191+
}
164192
}
165193
}else{
166194
input_type = "question";

0 commit comments

Comments
 (0)