diff --git a/app/src/main/mqtt-manager.js b/app/src/main/mqtt-manager.js index cd13303..e0d3c31 100644 --- a/app/src/main/mqtt-manager.js +++ b/app/src/main/mqtt-manager.js @@ -450,15 +450,16 @@ class MqttManager { addTopic(serverId, topic, qos = 1) { let server = this.servers.get(serverId); if (!server) { - return false; + return null; } if (server.topics.find((t) => t.topic === topic)) { - return false; + return null; } let topicId = 'topic_' + Date.now() + '_' + Math.random().toString(36).slice(2, 6); - server.topics.push({ id: topicId, topic, qos, subscribed: false }); + let newTopic = { id: topicId, topic, qos, subscribed: false }; + server.topics.push(newTopic); this.saveData(); @@ -467,7 +468,7 @@ class MqttManager { this._doSubscribe(serverId, topic, { qos }); } - return true; + return newTopic; } diff --git a/app/src/renderer/src/stores/mqtt.js b/app/src/renderer/src/stores/mqtt.js index ff91ea1..691b554 100644 --- a/app/src/renderer/src/stores/mqtt.js +++ b/app/src/renderer/src/stores/mqtt.js @@ -191,7 +191,7 @@ export function useMqttStore() { if (result) { let srv = servers.value.find((s) => s.id === serverId); if (srv) { - srv.topics.push({ topic, qos, subscribed: false }); + srv.topics.push(result); } }