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)
This commit is contained in:
Zev Benjamin 2012-10-29 13:56:58 -04:00
parent cee3f87585
commit bc4447f9f8
1 changed files with 11 additions and 6 deletions

View File

@ -501,29 +501,34 @@ function start_reload_app() {
var idle_control; var idle_control;
var composing_timeout = 1000*60*10; var composing_timeout = 1000*60*10;
var home_timeout = 1000*60; 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.cancel();
idle_control = $(document).idle({'idle': home_timeout, idle_control = $(document).idle({'idle': home_timeout,
'onIdle': do_reload_app}); '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 () { compose_started_handler = function () {
idle_control.cancel(); idle_control.cancel();
idle_control = $(document).idle({'idle': composing_timeout, idle_control = $(document).idle({'idle': composing_timeout,
'onIdle': do_reload_app_preserving_compose}); '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()) { if (compose.composing()) {
idle_control = $(document).idle({'idle': composing_timeout, idle_control = $(document).idle({'idle': composing_timeout,
'onIdle': do_reload_app_preserving_compose}); '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 { } else {
idle_control = $(document).idle({'idle': home_timeout, idle_control = $(document).idle({'idle': home_timeout,
'onIdle': do_reload_app}); 'onIdle': do_reload_app});
$(document).one('compose_started.zephyr', compose_started_handler); $(document).on('compose_started.zephyr', compose_started_handler);
} }
} }