Don't send tutorial timeout message if we're no longer running.

If the system was waiting for you to reply and you replied 'exit', the
tutorial would stop -- but our thing that was waiting for you to reply
would continue waiting. It would eventually timeout and send you the
heartbroken "I didn't hear from you so I stopped waiting" message.

Chances are, you were unsubscribed so you didn't see it, but we
should still just not send it.

(imported from commit 694e442bc29b32efd59f08b4b8b5f573768aea21)
This commit is contained in:
Waseem Daher
2013-04-22 17:25:42 -04:00
parent a251b12ec7
commit 5951c7eb00

View File

@@ -48,6 +48,8 @@ function stream_message(subject, message) {
// populated later -- should be e.g. tutorial-wdaher // populated later -- should be e.g. tutorial-wdaher
var my_tutorial_stream; var my_tutorial_stream;
var tutorial_running = false;
function stream_to_me(message) { function stream_to_me(message) {
return message.type === 'stream' && message.to === my_tutorial_stream; return message.type === 'stream' && message.to === my_tutorial_stream;
} }
@@ -87,6 +89,10 @@ function wait_for_message(time_to_wait_sec, condition) {
return $.Deferred(function (deferred) { return $.Deferred(function (deferred) {
var numCalls = 0; var numCalls = 0;
var intervalId = setInterval(function () { var intervalId = setInterval(function () {
if (!tutorial_running) {
clearInterval(intervalId);
deferred.fail();
}
numCalls += 1; numCalls += 1;
if (numCalls > time_to_wait_sec * (1000 / POLL_INTERVAL_MS)) { if (numCalls > time_to_wait_sec * (1000 / POLL_INTERVAL_MS)) {
clearInterval(intervalId); clearInterval(intervalId);
@@ -164,8 +170,6 @@ function pick_hello_stream() {
return hello_stream; return hello_stream;
} }
var tutorial_running = false;
function run_tutorial(stepNumber) { function run_tutorial(stepNumber) {
if (stepNumber >= script.length) { if (stepNumber >= script.length) {
return; return;