From c25c8bc872b2c631d5ea9c19fbc6d8e8081cb83d Mon Sep 17 00:00:00 2001 From: Razvan Tomegea Date: Mon, 16 Dec 2024 09:47:09 +0200 Subject: [PATCH 1/2] Fixed logout doesn't work when `shouldBroadcastLogoutAcrossTabs` is `false` (#1348) --- CHANGELOG.md | 2 ++ src/utils/logout.ts | 11 +++-------- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f9ca31fb9..4ab2449e0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +- [Fixed logout doesn't work when `shouldBroadcastLogoutAcrossTabs` is `false`](https://github.com/multiversx/mx-sdk-dapp/pull/1348) + ## [[v3.1.3](https://github.com/multiversx/mx-sdk-dapp/pull/1347)] - 2024-12-13 - [Added session ID in the handshake payload to allow multiple DApp connections in parallel tabs](https://github.com/multiversx/mx-sdk-dapp/pull/1346) diff --git a/src/utils/logout.ts b/src/utils/logout.ts index 4a07aec75..c633b5f8d 100644 --- a/src/utils/logout.ts +++ b/src/utils/logout.ts @@ -54,7 +54,7 @@ export async function logout( hasConsentPopup: false } ) { - let address = ''; + const address = await getAddress(); const provider = getAccountProvider(); const providerType = getProviderType(provider); const isWalletProvider = providerType === LoginMethodsEnum.wallet; @@ -64,13 +64,8 @@ export async function logout( return provider.relogin(); } - if (options.shouldBroadcastLogoutAcrossTabs) { - try { - address = await getAddress(); - broadcastLogoutAcrossTabs(address); - } catch (err) { - console.error('error fetching logout address', err); - } + if (address && options.shouldBroadcastLogoutAcrossTabs) { + broadcastLogoutAcrossTabs(address); } const url = addOriginToLocationPath(callbackUrl); From 9e773a2118e43e9b6aa67879a90d0785bb6e87ae Mon Sep 17 00:00:00 2001 From: "razvan.tomegea" Date: Mon, 16 Dec 2024 09:53:32 +0200 Subject: [PATCH 2/2] 3.1.4 --- CHANGELOG.md | 2 ++ package.json | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4ab2449e0..6d455efcb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [[v3.1.4](https://github.com/multiversx/mx-sdk-dapp/pull/1349)] - 2024-12-16 + - [Fixed logout doesn't work when `shouldBroadcastLogoutAcrossTabs` is `false`](https://github.com/multiversx/mx-sdk-dapp/pull/1348) ## [[v3.1.3](https://github.com/multiversx/mx-sdk-dapp/pull/1347)] - 2024-12-13 diff --git a/package.json b/package.json index 5964bdbeb..844ca38a5 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@multiversx/sdk-dapp", - "version": "3.1.3", + "version": "3.1.4", "description": "A library to hold the main logic for a dapp on the MultiversX blockchain", "author": "MultiversX", "license": "GPL-3.0-or-later",