From 34ec05d4b4f1146b8ecf9be8f9452a46c4a54484 Mon Sep 17 00:00:00 2001 From: shortcutme Date: Tue, 18 Jul 2017 20:55:53 +0200 Subject: [PATCH] Fix notification id collision --- src/Ui/media/Wrapper.coffee | 2 +- src/Ui/media/all.js | 23 ++++++++++++----------- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/src/Ui/media/Wrapper.coffee b/src/Ui/media/Wrapper.coffee index eae824be..3e3f79ea 100644 --- a/src/Ui/media/Wrapper.coffee +++ b/src/Ui/media/Wrapper.coffee @@ -49,7 +49,7 @@ class Wrapper @sendInner message # Pass message to inner frame else if cmd == "notification" # Display notification type = message.params[0] - id = "notification-#{message.id}" + id = "notification-ws-#{message.id}" if "-" in message.params[0] # - in first param: message id defined [id, type] = message.params[0].split("-") @notifications.add(id, type, message.params[1], message.params[2]) diff --git a/src/Ui/media/all.js b/src/Ui/media/all.js index 325379e5..2791c209 100644 --- a/src/Ui/media/all.js +++ b/src/Ui/media/all.js @@ -684,11 +684,11 @@ jQuery.extend( jQuery.easing, (function() { var Notifications, - __slice = [].slice; + slice = [].slice; Notifications = (function() { - function Notifications(_at_elem) { - this.elem = _at_elem; + function Notifications(elem1) { + this.elem = elem1; this; } @@ -707,14 +707,14 @@ jQuery.extend( jQuery.easing, }; Notifications.prototype.add = function(id, type, body, timeout) { - var elem, width, _i, _len, _ref; + var elem, i, len, ref, width; if (timeout == null) { timeout = 0; } id = id.replace(/[^A-Za-z0-9]/g, ""); - _ref = $(".notification-" + id); - for (_i = 0, _len = _ref.length; _i < _len; _i++) { - elem = _ref[_i]; + ref = $(".notification-" + id); + for (i = 0, len = ref.length; i < len; i++) { + elem = ref[i]; this.close($(elem)); } elem = $(".notification.template", this.elem).clone().removeClass("template"); @@ -791,8 +791,8 @@ jQuery.extend( jQuery.easing, Notifications.prototype.log = function() { var args; - args = 1 <= arguments.length ? __slice.call(arguments, 0) : []; - return console.log.apply(console, ["[Notifications]"].concat(__slice.call(args))); + args = 1 <= arguments.length ? slice.call(arguments, 0) : []; + return console.log.apply(console, ["[Notifications]"].concat(slice.call(args))); }; return Notifications; @@ -804,6 +804,7 @@ jQuery.extend( jQuery.easing, }).call(this); + /* ---- src/Ui/media/Wrapper.coffee ---- */ @@ -880,7 +881,7 @@ jQuery.extend( jQuery.easing, } } else if (cmd === "notification") { type = message.params[0]; - id = "notification-" + message.id; + id = "notification-ws-" + message.id; if (indexOf.call(message.params[0], "-") >= 0) { ref = message.params[0].split("-"), id = ref[0], type = ref[1]; } @@ -1550,4 +1551,4 @@ jQuery.extend( jQuery.easing, window.wrapper = new Wrapper(ws_url); -}).call(this); +}).call(this); \ No newline at end of file