Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down Expand Up @@ -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",
Expand Down
11 changes: 6 additions & 5 deletions src/ws-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand All @@ -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,
Expand Down