From 0ff189e4c7a53e2155b4ef412e1d137171faf590 Mon Sep 17 00:00:00 2001 From: Jan Schneider Date: Mon, 8 Feb 2010 23:06:59 +0100 Subject: [PATCH] Fix race condition when new alarms arrive faster than growlers are created. --- kronolith/js/kronolith.js | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/kronolith/js/kronolith.js b/kronolith/js/kronolith.js index a609e057b..b84923c23 100644 --- a/kronolith/js/kronolith.js +++ b/kronolith/js/kronolith.js @@ -139,6 +139,10 @@ KronolithCore = { if (this.alarms.indexOf(m.alarm.id) != -1) { break; } + if (m.type == 'horde.alarm') { + this.alarms.push(m.alarm.id); + } + message = m.alarm.title.escapeHTML(); if (!Object.isUndefined(m.alarm.ajax)) { message = new Element('a') @@ -164,15 +168,8 @@ KronolithCore = { sticky: true }); - document.observe('Growler:created', function() { - if (m.type == 'horde.alarm') { - this.alarms.push(m.alarm.id); - } - }.bind(this)); document.observe('Growler:destroyed', function() { - if (m.type == 'horde.alarm') { - this.alarms = this.alarms.without(m.alarm.id); - } + this.alarms = this.alarms.without(m.alarm.id); }.bind(this)); if (m.alarm.user) { -- 2.11.0