Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix clear initiated login #1301

Merged
merged 2 commits into from
Nov 6, 2024
Merged
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
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

- [Fix clear initiated login](https://github.com/multiversx/mx-sdk-dapp/pull/1301)

## [[v3.0.8](https://github.com/multiversx/mx-sdk-dapp/pull/1299)] - 2024-11-04

- [Update skip method to clear only initiated login state](https://github.com/multiversx/mx-sdk-dapp/pull/1298)

- [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)

Expand Down
28 changes: 19 additions & 9 deletions src/hooks/login/helpers/clearInitiatedLogins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,29 @@ import { IframeProvider } from 'lib/sdkWebWalletIframeProvider';
import { LoginMethodsEnum } from 'types';

export const clearInitiatedLogins = (props?: {
intiatedLoginMethod: LoginMethodsEnum;
skipLoginMethod: LoginMethodsEnum;
}) => {
Object.values(LoginMethodsEnum).forEach((method) => {
if (props?.intiatedLoginMethod && method !== props.intiatedLoginMethod) {
if (method === props?.skipLoginMethod) {
return;
}
const crossWindowProvider = CrossWindowProvider.getInstance();
if (crossWindowProvider.isInitialized()) {
crossWindowProvider.dispose();
}
const iframeProvider = IframeProvider.getInstance();
if (iframeProvider.isInitialized()) {
iframeProvider.dispose();
switch (method) {
case LoginMethodsEnum.crossWindow: {
const crossWindowProvider = CrossWindowProvider.getInstance();
if (crossWindowProvider.isInitialized()) {
crossWindowProvider.dispose();
}
break;
}
case LoginMethodsEnum.iframe: {
const iframeProvider = IframeProvider.getInstance();
if (iframeProvider.isInitialized()) {
iframeProvider.dispose();
}
break;
}
default:
break;
}
});

Expand Down
2 changes: 1 addition & 1 deletion src/hooks/login/useCrossWindowLogin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export const useCrossWindowLogin = ({
}

clearInitiatedLogins({
intiatedLoginMethod: LoginMethodsEnum.crossWindow
skipLoginMethod: LoginMethodsEnum.crossWindow
});

setIsLoading(true);
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/login/useIframeLogin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export const useIframeLogin = ({
}

clearInitiatedLogins({
intiatedLoginMethod: LoginMethodsEnum.iframe
skipLoginMethod: LoginMethodsEnum.iframe
});

setIsLoading(true);
Expand Down
Loading