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>
|
||||
</div>
|
||||
<div class="form-row mqtt-persistence">
|
||||
<label for="node-config-input-unsubscribeOnDisconnect" style="width: auto;">
|
||||
<input type="checkbox" id="node-config-input-unsubscribeOnDisconnect" 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>
|
||||
<label for="node-config-input-autoUnsubscribe" style="width: auto;">
|
||||
<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-autoUnsubscribe-label" data-i18n="mqtt.label.autoUnsubscribe"></span>
|
||||
</label>
|
||||
</div>
|
||||
<div class="form-row mqtt5">
|
||||
@ -511,7 +511,7 @@
|
||||
label: RED._("node-red:mqtt.label.keepalive"),
|
||||
validate:RED.validators.number(false)},
|
||||
cleansession: {value: true},
|
||||
unsubscribeOnDisconnect: {value: true},
|
||||
autoUnsubscribe: {value: true},
|
||||
birthTopic: {value:"", validate:validateMQTTPublishTopic},
|
||||
birthQos: {value:"0"},
|
||||
birthRetain: {value:"false"},
|
||||
@ -627,9 +627,9 @@
|
||||
this.cleansession = true;
|
||||
$("#node-config-input-cleansession").prop("checked",true);
|
||||
}
|
||||
if (typeof this.unsubscribeOnDisconnect === 'undefined') {
|
||||
this.unsubscribeOnDisconnect = true;
|
||||
$("#node-config-input-unsubscribeOnDisconnect").prop("checked",true);
|
||||
if (typeof this.autoUnsubscribe === 'undefined') {
|
||||
this.autoUnsubscribe = true;
|
||||
$("#node-config-input-autoUnsubscribe").prop("checked",true);
|
||||
}
|
||||
if (typeof this.usetls === 'undefined') {
|
||||
this.usetls = false;
|
||||
|
@ -482,7 +482,7 @@ module.exports = function(RED) {
|
||||
setIfHasProperty(opts, node, "protocolVersion", init);
|
||||
setIfHasProperty(opts, node, "keepalive", init);
|
||||
setIfHasProperty(opts, node, "cleansession", init);
|
||||
setIfHasProperty(opts, node, "unsubscribeOnDisconnect", init);
|
||||
setIfHasProperty(opts, node, "autoUnsubscribe", init);
|
||||
setIfHasProperty(opts, node, "topicAliasMaximum", init);
|
||||
setIfHasProperty(opts, node, "maximumPacketSize", init);
|
||||
setIfHasProperty(opts, node, "receiveMaximum", init);
|
||||
@ -591,8 +591,8 @@ module.exports = function(RED) {
|
||||
if (typeof node.cleansession === 'undefined') {
|
||||
node.cleansession = true;
|
||||
}
|
||||
if (typeof node.unsubscribeOnDisconnect === 'undefined') {
|
||||
node.unsubscribeOnDisconnect = true;
|
||||
if (typeof node.autoUnsubscribe === 'undefined') {
|
||||
node.autoUnsubscribe = true;
|
||||
}
|
||||
|
||||
//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.keepalive = node.keepalive;
|
||||
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.reconnectPeriod = RED.settings.mqttReconnectTime||5000;
|
||||
delete node.options.protocolId; //V4+ default
|
||||
@ -1233,14 +1233,14 @@ module.exports = function(RED) {
|
||||
node.on('close', function(removed, done) {
|
||||
if (node.brokerConn) {
|
||||
if(node.isDynamic) {
|
||||
if (node.brokerConn.options.unsubscribeOnDisconnect) {
|
||||
if (node.brokerConn.options.autoUnsubscribe) {
|
||||
Object.keys(node.dynamicSubs).forEach(function (topic) {
|
||||
node.brokerConn.unsubscribe(topic, node.id, removed);
|
||||
});
|
||||
node.dynamicSubs = {};
|
||||
}
|
||||
} else {
|
||||
if (node.brokerConn.options.unsubscribeOnDisconnect) {
|
||||
if (node.brokerConn.options.autoUnsubscribe) {
|
||||
node.brokerConn.unsubscribe(node.topic, node.id, removed);
|
||||
}
|
||||
}
|
||||
|
@ -362,7 +362,7 @@
|
||||
"port": "Port",
|
||||
"keepalive": "Keep-Alive",
|
||||
"cleansession": "Bereinigte Sitzung (clean session) verwenden",
|
||||
"unsubscribeOnDisconnect": "Abonnement bei Verbindungsende automatisch beenden",
|
||||
"autoUnsubscribe": "Abonnement bei Verbindungsende automatisch beenden",
|
||||
"cleanstart": "Verwende bereinigten Start",
|
||||
"use-tls": "TLS",
|
||||
"tls-config": "TLS-Konfiguration",
|
||||
|
@ -414,7 +414,7 @@
|
||||
"port": "Port",
|
||||
"keepalive": "Keep Alive",
|
||||
"cleansession": "Use clean session",
|
||||
"unsubscribeOnDisconnect": "Automatically unsubscribe when disconnecting",
|
||||
"autoUnsubscribe": "Automatically unsubscribe when disconnecting",
|
||||
"cleanstart": "Use clean start",
|
||||
"use-tls": "Use TLS",
|
||||
"tls-config": "TLS Configuration",
|
||||
|
Loading…
Reference in New Issue
Block a user