From e2413e8137ca0ba587d50039bbca267fb9be2ebf Mon Sep 17 00:00:00 2001 From: Tim Abbott Date: Fri, 9 Aug 2013 17:02:43 -0400 Subject: [PATCH] Defer processing of get_old_messages results during tutorial. Previously we would just discard the results of get_old_messages, which meant that any messages sent either while you were doing the tutorial or that you started out with (as in the case of the CUSTOMER3 experiment) would be lost until you reloaded. (imported from commit f5280c091ab6ed7c2af6eb8fe49c0fa6b997ac97) --- static/js/tutorial.js | 12 +++++++++--- static/js/zulip.js | 8 ++++++++ 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/static/js/tutorial.js b/static/js/tutorial.js index e967b62126..5de957745f 100644 --- a/static/js/tutorial.js +++ b/static/js/tutorial.js @@ -3,6 +3,7 @@ var tutorial = (function () { var exports = {}; var is_running = false; var event_handlers = {}; +var deferred_work = []; // We'll temporarily set stream colors for the streams we use in the demo // tutorial messages. @@ -223,6 +224,10 @@ function create_and_show_popover(target_div, placement, title, content_template) $(".popover").css("z-index", 20001); } +exports.defer = function (callback) { + deferred_work.push(callback); +}; + function finale() { var finale_modal = $("#tutorial-finale"); $(".screen").css({opacity: 0.0}); @@ -245,6 +250,10 @@ function finale() { util.show_first_run_message(); current_msg_list.rerender(); enable_event_handlers(); + _.each(deferred_work, function (callback) { + callback(); + }); + deferred_work = []; } function reply() { @@ -397,9 +406,6 @@ exports.start = function () { } narrow.deactivate(); - // If you somehow have messages, temporarily remove them from the visible - // feed. - current_msg_list.clear(); // Set temporarly colors for the streams used in the tutorial. real_stream_info = subs.stream_info(); subs.stream_info(tutorial_stream_info); diff --git a/static/js/zulip.js b/static/js/zulip.js index a7219d58a2..93701a7cef 100644 --- a/static/js/zulip.js +++ b/static/js/zulip.js @@ -1059,6 +1059,14 @@ function get_old_messages_success(data, opts) { }, 25); return; } + if (tutorial.is_running()) { + // Don't actually process the messages until the tutorial is + // finished, but do disable the loading indicator so it isn't + // distracting in the background + util.destroy_loading_indicator($('#page_loading_indicator')); + tutorial.defer(function () { get_old_messages_success(data, opts); }); + return; + } if (opts.msg_list.narrowed && opts.msg_list !== current_msg_list) { // We unnarrowed before receiving new messages so