Skip to content

Commit

Permalink
Don't unsubscribe unless there are existing topics
Browse files Browse the repository at this point in the history
  • Loading branch information
optionsome committed Jun 19, 2019
1 parent 7828de7 commit 3752c4d
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion app/util/mqttClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,9 @@ export function parseMessage(topic, message, agency) {
export function changeTopics(settings, actionContext) {
const { client, oldTopics } = settings;

client.unsubscribe(oldTopics);
if (Array.isArray(oldTopics) && oldTopics.length > 0) {
client.unsubscribe(oldTopics);
}
// remove existing vehicles/topics
actionContext.dispatch('RealTimeClientReset');
const topics = settings.options.map(option => getTopic(option, settings));
Expand Down

0 comments on commit 3752c4d

Please sign in to comment.