mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
Refactor to use the already existing autoUnsubscribe property
The tests had an unused property called autoUnsubscribe. I refactored the code to use this wording too.
This commit is contained in:
parent
b5dfd62c99
commit
8dcc530f44
@ -250,9 +250,9 @@
|
|||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-row mqtt-persistence">
|
<div class="form-row mqtt-persistence">
|
||||||
<label for="node-config-input-unsubscribeOnDisconnect" style="width: auto;">
|
<label for="node-config-input-autoUnsubscribe" style="width: auto;">
|
||||||
<input type="checkbox" id="node-config-input-unsubscribeOnDisconnect" style="position: relative;vertical-align: bottom; top: -2px; width: 15px;height: 15px;">
|
<input type="checkbox" id="node-config-input-autoUnsubscribe" style="position: relative;vertical-align: bottom; top: -2px; width: 15px;height: 15px;">
|
||||||
<span id="node-config-input-unsubscribeOnDisconnect-label" data-i18n="mqtt.label.unsubscribeOnDisconnect"></span>
|
<span id="node-config-input-autoUnsubscribe-label" data-i18n="mqtt.label.autoUnsubscribe"></span>
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-row mqtt5">
|
<div class="form-row mqtt5">
|
||||||
@ -511,7 +511,7 @@
|
|||||||
label: RED._("node-red:mqtt.label.keepalive"),
|
label: RED._("node-red:mqtt.label.keepalive"),
|
||||||
validate:RED.validators.number(false)},
|
validate:RED.validators.number(false)},
|
||||||
cleansession: {value: true},
|
cleansession: {value: true},
|
||||||
unsubscribeOnDisconnect: {value: true},
|
autoUnsubscribe: {value: true},
|
||||||
birthTopic: {value:"", validate:validateMQTTPublishTopic},
|
birthTopic: {value:"", validate:validateMQTTPublishTopic},
|
||||||
birthQos: {value:"0"},
|
birthQos: {value:"0"},
|
||||||
birthRetain: {value:"false"},
|
birthRetain: {value:"false"},
|
||||||
@ -627,9 +627,9 @@
|
|||||||
this.cleansession = true;
|
this.cleansession = true;
|
||||||
$("#node-config-input-cleansession").prop("checked",true);
|
$("#node-config-input-cleansession").prop("checked",true);
|
||||||
}
|
}
|
||||||
if (typeof this.unsubscribeOnDisconnect === 'undefined') {
|
if (typeof this.autoUnsubscribe === 'undefined') {
|
||||||
this.unsubscribeOnDisconnect = true;
|
this.autoUnsubscribe = true;
|
||||||
$("#node-config-input-unsubscribeOnDisconnect").prop("checked",true);
|
$("#node-config-input-autoUnsubscribe").prop("checked",true);
|
||||||
}
|
}
|
||||||
if (typeof this.usetls === 'undefined') {
|
if (typeof this.usetls === 'undefined') {
|
||||||
this.usetls = false;
|
this.usetls = false;
|
||||||
|
@ -482,7 +482,7 @@ module.exports = function(RED) {
|
|||||||
setIfHasProperty(opts, node, "protocolVersion", init);
|
setIfHasProperty(opts, node, "protocolVersion", init);
|
||||||
setIfHasProperty(opts, node, "keepalive", init);
|
setIfHasProperty(opts, node, "keepalive", init);
|
||||||
setIfHasProperty(opts, node, "cleansession", init);
|
setIfHasProperty(opts, node, "cleansession", init);
|
||||||
setIfHasProperty(opts, node, "unsubscribeOnDisconnect", init);
|
setIfHasProperty(opts, node, "autoUnsubscribe", init);
|
||||||
setIfHasProperty(opts, node, "topicAliasMaximum", init);
|
setIfHasProperty(opts, node, "topicAliasMaximum", init);
|
||||||
setIfHasProperty(opts, node, "maximumPacketSize", init);
|
setIfHasProperty(opts, node, "maximumPacketSize", init);
|
||||||
setIfHasProperty(opts, node, "receiveMaximum", init);
|
setIfHasProperty(opts, node, "receiveMaximum", init);
|
||||||
@ -591,8 +591,8 @@ module.exports = function(RED) {
|
|||||||
if (typeof node.cleansession === 'undefined') {
|
if (typeof node.cleansession === 'undefined') {
|
||||||
node.cleansession = true;
|
node.cleansession = true;
|
||||||
}
|
}
|
||||||
if (typeof node.unsubscribeOnDisconnect === 'undefined') {
|
if (typeof node.autoUnsubscribe === 'undefined') {
|
||||||
node.unsubscribeOnDisconnect = true;
|
node.autoUnsubscribe = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//use url or build a url from usetls://broker:port
|
//use url or build a url from usetls://broker:port
|
||||||
@ -664,7 +664,7 @@ module.exports = function(RED) {
|
|||||||
node.options.password = node.password;
|
node.options.password = node.password;
|
||||||
node.options.keepalive = node.keepalive;
|
node.options.keepalive = node.keepalive;
|
||||||
node.options.clean = node.cleansession;
|
node.options.clean = node.cleansession;
|
||||||
node.options.unsubscribeOnDisconnect = node.unsubscribeOnDisconnect;
|
node.options.autoUnsubscribe = node.autoUnsubscribe;
|
||||||
node.options.clientId = node.clientid || 'nodered_' + RED.util.generateId();
|
node.options.clientId = node.clientid || 'nodered_' + RED.util.generateId();
|
||||||
node.options.reconnectPeriod = RED.settings.mqttReconnectTime||5000;
|
node.options.reconnectPeriod = RED.settings.mqttReconnectTime||5000;
|
||||||
delete node.options.protocolId; //V4+ default
|
delete node.options.protocolId; //V4+ default
|
||||||
@ -1233,14 +1233,14 @@ module.exports = function(RED) {
|
|||||||
node.on('close', function(removed, done) {
|
node.on('close', function(removed, done) {
|
||||||
if (node.brokerConn) {
|
if (node.brokerConn) {
|
||||||
if(node.isDynamic) {
|
if(node.isDynamic) {
|
||||||
if (node.brokerConn.options.unsubscribeOnDisconnect) {
|
if (node.brokerConn.options.autoUnsubscribe) {
|
||||||
Object.keys(node.dynamicSubs).forEach(function (topic) {
|
Object.keys(node.dynamicSubs).forEach(function (topic) {
|
||||||
node.brokerConn.unsubscribe(topic, node.id, removed);
|
node.brokerConn.unsubscribe(topic, node.id, removed);
|
||||||
});
|
});
|
||||||
node.dynamicSubs = {};
|
node.dynamicSubs = {};
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (node.brokerConn.options.unsubscribeOnDisconnect) {
|
if (node.brokerConn.options.autoUnsubscribe) {
|
||||||
node.brokerConn.unsubscribe(node.topic, node.id, removed);
|
node.brokerConn.unsubscribe(node.topic, node.id, removed);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -362,7 +362,7 @@
|
|||||||
"port": "Port",
|
"port": "Port",
|
||||||
"keepalive": "Keep-Alive",
|
"keepalive": "Keep-Alive",
|
||||||
"cleansession": "Bereinigte Sitzung (clean session) verwenden",
|
"cleansession": "Bereinigte Sitzung (clean session) verwenden",
|
||||||
"unsubscribeOnDisconnect": "Abonnement bei Verbindungsende automatisch beenden",
|
"autoUnsubscribe": "Abonnement bei Verbindungsende automatisch beenden",
|
||||||
"cleanstart": "Verwende bereinigten Start",
|
"cleanstart": "Verwende bereinigten Start",
|
||||||
"use-tls": "TLS",
|
"use-tls": "TLS",
|
||||||
"tls-config": "TLS-Konfiguration",
|
"tls-config": "TLS-Konfiguration",
|
||||||
|
@ -414,7 +414,7 @@
|
|||||||
"port": "Port",
|
"port": "Port",
|
||||||
"keepalive": "Keep Alive",
|
"keepalive": "Keep Alive",
|
||||||
"cleansession": "Use clean session",
|
"cleansession": "Use clean session",
|
||||||
"unsubscribeOnDisconnect": "Automatically unsubscribe when disconnecting",
|
"autoUnsubscribe": "Automatically unsubscribe when disconnecting",
|
||||||
"cleanstart": "Use clean start",
|
"cleanstart": "Use clean start",
|
||||||
"use-tls": "Use TLS",
|
"use-tls": "Use TLS",
|
||||||
"tls-config": "TLS Configuration",
|
"tls-config": "TLS Configuration",
|
||||||
|
Loading…
Reference in New Issue
Block a user