diff --git a/package.json b/package.json index 16e304d..cb895c8 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "libshv-js", - "version": "3.21.0", + "version": "3.22.0", "description": "Typescript implementation of libshv", "main": "dist/index.js", "types": "dist/index.d.ts", @@ -41,7 +41,7 @@ "js-pkce": "^2.0.0", "@vueuse/core": "^13.5.0", "vue": "^3.5.18", - "zod": "^4.0.5" + "zod": "4.0.5 - 4.0.10" }, "devDependencies": { "@typescript-eslint/parser": "^8.38.0", diff --git a/src/ws-client.ts b/src/ws-client.ts index 5df8c54..341ff77 100644 --- a/src/ws-client.ts +++ b/src/ws-client.ts @@ -544,11 +544,6 @@ class WsClient { } subscribe(subscriber: string, path: string, method: string, callback: SubscriptionCallback) { - if (this.subscriptions.some(val => val.subscriber === subscriber && val.path === path && val.method === method)) { - this.logDebug(`Already subscribed {$path}:${method} for subscriber ${subscriber}`); - return; - } - // If this path:method has not been subscribed on the broker, do it now if (!this.subscriptions.some(val => val.path === path && val.method === method)) { this.callRpcMethod('.broker/app', 'subscribe', makeMap({ @@ -558,6 +553,12 @@ class WsClient { }); } + const oldSubscriber = this.subscriptions.findIndex(val => val.subscriber === subscriber && val.path === path && val.method === method); + if (oldSubscriber !== -1) { + this.logDebug(`Removing previous subscription {$path}:${method} for subscriber ${subscriber}`); + this.subscriptions.splice(oldSubscriber, 1); + } + this.subscriptions.push({ subscriber, path,