From 5849c0631435b89bb1abd584d67015b27e8a1ec0 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Tue, 30 Jul 2019 08:17:29 +0200 Subject: [PATCH] storage.js: Don't try and allow to register events for non-local backends --- public/js/icinga/storage.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/public/js/icinga/storage.js b/public/js/icinga/storage.js index 8cdabb86f..c48aea522 100644 --- a/public/js/icinga/storage.js +++ b/public/js/icinga/storage.js @@ -171,6 +171,10 @@ * @returns {void} */ onChange: function(key, callback, context) { + if (this.backend !== window.localStorage) { + throw new Error('[Storage] Only the localStorage emits events'); + } + var prefixedKey = this.prefixKey(key); if (typeof Icinga.Storage.subscribers[prefixedKey] === 'undefined') { @@ -273,7 +277,10 @@ this.storage = storage; this.key = key; - storage.onChange(key, this.onChange, this); + if (storage.backend === window.localStorage) { + storage.onChange(key, this.onChange, this); + } + return this; },