1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

Fixes bug that prevented unsubscribe from WebSockets, browser side. Fixes node-red/node-red/#562

This commit is contained in:
Emil Öberg 2015-02-14 22:25:25 +01:00
parent cc095e4edf
commit 33d24f79ce

View File

@ -95,15 +95,15 @@ RED.comms = (function() {
}
function unsubscribe(topic,callback) {
if (subscriptions.topic) {
for (var i=0;i<subscriptions.topic.length;i++) {
if (subscriptions.topic[i] === callback) {
subscriptions.topic.splice(i,1);
if (subscriptions[topic]) {
for (var i=0;i<subscriptions[topic].length;i++) {
if (subscriptions[topic][i] === callback) {
subscriptions[topic].splice(i,1);
break;
}
}
if (subscriptions.topic.length === 0) {
delete subscriptions.topic;
if (subscriptions[topic].length === 0) {
delete subscriptions[topic];
}
}
}