From 3d72b717964785454c16e4973b7bfeb919b5e294 Mon Sep 17 00:00:00 2001 From: DanutIlie <42973343+DanutIlie@users.noreply.github.com> Date: Mon, 4 Nov 2024 17:24:34 +0200 Subject: [PATCH] update skip method to clear only initiated login state (#1298) * update skip method to clear only initiated login state * Update CHANGELOG.md * rename to intiatedLoginMethod --- CHANGELOG.md | 11 +++++++++++ src/hooks/login/helpers/clearInitiatedLogins.ts | 6 ++++-- src/hooks/login/useCrossWindowLogin.ts | 2 +- src/hooks/login/useIframeLogin.ts | 2 +- 4 files changed, 17 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index befdee839..3a9bfb589 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,33 +7,44 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +- [Update skip method to clear only initiated login state](https://github.com/multiversx/mx-sdk-dapp/pull/1298) + ## [[v3.0.7](https://github.com/multiversx/mx-sdk-dapp/pull/1296)] - 2024-11-01 + - [Updated Iframe provider imports](https://github.com/multiversx/mx-sdk-dapp/pull/1297) - [Fixed Iframe provider reload](https://github.com/multiversx/mx-sdk-dapp/pull/1295) ## [[v3.0.6](https://github.com/multiversx/mx-sdk-dapp/pull/1294)] - 2024-11-01 + - [Fixed `location.assign` in extension context](https://github.com/multiversx/mx-sdk-dapp/pull/1293) ## [[v3.0.5](https://github.com/multiversx/mx-sdk-dapp/pull/1292)] - 2024-11-01 + - [Added ability to close modal on Escape key press](https://github.com/multiversx/mx-sdk-dapp/pull/1291) ## [[v3.0.4](https://github.com/multiversx/mx-sdk-dapp/pull/1290)] - 2024-10-31 + - [Update passkey provider to use sign modals](https://github.com/multiversx/mx-sdk-dapp/pull/1289) - [Fixed sass warnings](https://github.com/multiversx/mx-sdk-dapp/pull/1288) ## [[v3.0.3](https://github.com/multiversx/mx-sdk-dapp/pull/1287)] - 2024-10-28 + - [Fixed ledger shows redundant error on login](https://github.com/multiversx/mx-sdk-dapp/pull/1286) ## [[v3.0.2](https://github.com/multiversx/mx-sdk-dapp/pull/1285)] - 2024-10-22 + - [Upgrade @multiversx/sdk-passkey-provider](https://github.com/multiversx/mx-sdk-dapp/pull/1284) ## [[v3.0.1](https://github.com/multiversx/mx-sdk-dapp/pull/1283)] - 2024-10-22 + - [Upgrade sdk-core to v.13.12.0](https://github.com/multiversx/mx-sdk-dapp/pull/1282) ## [⚠️ Breaking ⚠️[v3.0.0](https://github.com/multiversx/mx-sdk-dapp/pull/1281)] - 2024-10-21 + - [Upgrade providers login methods & signMessage. Upgrade sdk-core to v.13](https://github.com/multiversx/mx-sdk-dapp/pull/1279) ## [[v2.40.11](https://github.com/multiversx/mx-sdk-dapp/pull/1280)] - 2024-10-09 + - [Fixed axios interceptor concurrent calls](https://github.com/multiversx/mx-sdk-dapp/pull/1279) ## [[v2.40.10](https://github.com/multiversx/mx-sdk-dapp/pull/1277)] - 2024-10-04 diff --git a/src/hooks/login/helpers/clearInitiatedLogins.ts b/src/hooks/login/helpers/clearInitiatedLogins.ts index 70832e26a..ec158e3cd 100644 --- a/src/hooks/login/helpers/clearInitiatedLogins.ts +++ b/src/hooks/login/helpers/clearInitiatedLogins.ts @@ -2,9 +2,11 @@ import { CrossWindowProvider } from 'lib/sdkWebWalletCrossWindowProvider'; import { IframeProvider } from 'lib/sdkWebWalletIframeProvider'; import { LoginMethodsEnum } from 'types'; -export const clearInitiatedLogins = (props?: { skip: LoginMethodsEnum }) => { +export const clearInitiatedLogins = (props?: { + intiatedLoginMethod: LoginMethodsEnum; +}) => { Object.values(LoginMethodsEnum).forEach((method) => { - if (props?.skip && method === props.skip) { + if (props?.intiatedLoginMethod && method !== props.intiatedLoginMethod) { return; } const crossWindowProvider = CrossWindowProvider.getInstance(); diff --git a/src/hooks/login/useCrossWindowLogin.ts b/src/hooks/login/useCrossWindowLogin.ts index fa991f6a7..5fcecbabb 100644 --- a/src/hooks/login/useCrossWindowLogin.ts +++ b/src/hooks/login/useCrossWindowLogin.ts @@ -53,7 +53,7 @@ export const useCrossWindowLogin = ({ } clearInitiatedLogins({ - skip: LoginMethodsEnum.crossWindow + intiatedLoginMethod: LoginMethodsEnum.crossWindow }); setIsLoading(true); diff --git a/src/hooks/login/useIframeLogin.ts b/src/hooks/login/useIframeLogin.ts index 27d0d36b6..3c8fb4ea2 100644 --- a/src/hooks/login/useIframeLogin.ts +++ b/src/hooks/login/useIframeLogin.ts @@ -50,7 +50,7 @@ export const useIframeLogin = ({ } clearInitiatedLogins({ - skip: LoginMethodsEnum.iframe + intiatedLoginMethod: LoginMethodsEnum.iframe }); setIsLoading(true);