From bc4447f9f87bedf7d4b6d6de2f032eca7b96c374 Mon Sep 17 00:00:00 2001 From: Zev Benjamin Date: Mon, 29 Oct 2012 13:56:58 -0400 Subject: [PATCH] Prevent compose box from popping back up inappropriately on reload We weren't listing to compose finish events during reload previously, which meant that finishing a message was not handled in the same way as canceling a message. (imported from commit 4f2576121a8b5354c94348bc2896a2db8c4be000) --- zephyr/static/js/zephyr.js | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/zephyr/static/js/zephyr.js b/zephyr/static/js/zephyr.js index 674727dd46..b43e223478 100644 --- a/zephyr/static/js/zephyr.js +++ b/zephyr/static/js/zephyr.js @@ -501,29 +501,34 @@ function start_reload_app() { var idle_control; var composing_timeout = 1000*60*10; var home_timeout = 1000*60; - var compose_canceled_handler, compose_started_handler; + var compose_done_handler, compose_started_handler; - compose_canceled_handler = function () { + compose_done_handler = function () { idle_control.cancel(); idle_control = $(document).idle({'idle': home_timeout, 'onIdle': do_reload_app}); - $(document).one('compose_started.zephyr', compose_started_handler); + $(document).off('compose_canceled.zephyr compose_finished.zephyr', + compose_done_handler); + $(document).on('compose_started.zephyr', compose_started_handler); }; compose_started_handler = function () { idle_control.cancel(); idle_control = $(document).idle({'idle': composing_timeout, 'onIdle': do_reload_app_preserving_compose}); - $(document).one('compose_canceled.zephyr', compose_canceled_handler); + $(document).off('compose_started.zephyr', compose_started_handler); + $(document).on('compose_canceled.zephyr compose_finished.zephyr', + compose_done_handler); }; if (compose.composing()) { idle_control = $(document).idle({'idle': composing_timeout, 'onIdle': do_reload_app_preserving_compose}); - $(document).one('compose_canceled.zephyr', compose_canceled_handler); + $(document).on('compose_canceled.zephyr compose_finished.zephyr', + compose_done_handler); } else { idle_control = $(document).idle({'idle': home_timeout, 'onIdle': do_reload_app}); - $(document).one('compose_started.zephyr', compose_started_handler); + $(document).on('compose_started.zephyr', compose_started_handler); } }