Fix cleanup_event_queue being called multiple times during reload.

Apparently it isn't always the case that removal of jquery and the DOM
prevents cleanup_event_queue from being called via the postunload
hook, so add a check to avoid it being double-called.
This commit is contained in:
Tim Abbott 2016-03-30 23:01:52 -07:00
parent 59e2be2f5f
commit 6d2ae9abbc
2 changed files with 4 additions and 2 deletions

View File

@ -150,8 +150,8 @@ function cleanup_before_reload() {
// Free all the DOM in the main_div
$("#main_div").empty();
// Now that the DOM is empty our beforeunload callback has been
// removed.
// Now that the DOM is empty our beforeunload callback may
// have been removed, so explicitly remove event queue here.
server_events.cleanup_event_queue();
// Empty the large collections

View File

@ -379,6 +379,8 @@ exports.cleanup_event_queue = function cleanup_event_queue() {
if (page_params.event_queue_expired === true) {
return;
}
// Set expired because in a reload we may be called twice.
page_params.event_queue_expired = true;
channel.del({
url: '/json/events',
data: {queue_id: page_params.event_queue_id}