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:
parent
cc095e4edf
commit
33d24f79ce
@ -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];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user