From d123e08c212d7763f083e037ffeb9d613fa657bc Mon Sep 17 00:00:00 2001 From: Anton Alexeyev Date: Thu, 9 Oct 2025 11:25:33 +0700 Subject: [PATCH 1/2] Reconnect pulse client after token change Signed-off-by: Anton Alexeyev --- packages/presentation/src/pulse.ts | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/packages/presentation/src/pulse.ts b/packages/presentation/src/pulse.ts index 93681b8093a..822885f4bba 100644 --- a/packages/presentation/src/pulse.ts +++ b/packages/presentation/src/pulse.ts @@ -15,19 +15,23 @@ import { HulypulseClient } from '@hcengineering/hulypulse-client' import { getMetadata } from '@hcengineering/platform' import presentation from './plugin' -let pulseclient: HulypulseClient | undefined +let pulseClient: HulypulseClient | undefined +let currentToken: string | undefined export async function createPulseClient (): Promise { - if (pulseclient == null) { + const token = getMetadata(presentation.metadata.Token) + if (token !== currentToken) { + closePulseClient() + } + if (pulseClient == null) { const wsPulseUrl = getMetadata(presentation.metadata.PulseUrl) if (wsPulseUrl == null || wsPulseUrl.trim().length === 0) return undefined - const token = getMetadata(presentation.metadata.Token) - pulseclient = await HulypulseClient.connect(`${wsPulseUrl}?token=${token}`) + pulseClient = await HulypulseClient.connect(`${wsPulseUrl}?token=${token}`) } - return pulseclient + return pulseClient } export function closePulseClient (): void { - pulseclient?.close() - pulseclient = undefined + pulseClient?.close() + pulseClient = undefined } From 4b3dd96d8a394351835733b3ddef58cccc354f3c Mon Sep 17 00:00:00 2001 From: Anton Alexeyev Date: Thu, 9 Oct 2025 11:41:11 +0700 Subject: [PATCH 2/2] Fix token check Signed-off-by: Anton Alexeyev --- packages/presentation/src/pulse.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/presentation/src/pulse.ts b/packages/presentation/src/pulse.ts index 822885f4bba..9dfc305900b 100644 --- a/packages/presentation/src/pulse.ts +++ b/packages/presentation/src/pulse.ts @@ -23,10 +23,11 @@ export async function createPulseClient (): Promise if (token !== currentToken) { closePulseClient() } - if (pulseClient == null) { + if (pulseClient === undefined) { const wsPulseUrl = getMetadata(presentation.metadata.PulseUrl) if (wsPulseUrl == null || wsPulseUrl.trim().length === 0) return undefined pulseClient = await HulypulseClient.connect(`${wsPulseUrl}?token=${token}`) + currentToken = token } return pulseClient }