Skip to content

Commit

Permalink
refactor: removed useless delay
Browse files Browse the repository at this point in the history
  • Loading branch information
andreabadesso committed Jan 2, 2025
1 parent 7be5741 commit 64134bd
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 9 deletions.
3 changes: 0 additions & 3 deletions src/modules/reown.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@
* LICENSE file in the root directory of this source tree.
*/

import { WalletKit } from '@reown/walletkit/dist/types/client';
import { Core } from '@walletconnect/core/dist/types/core';

/**
* Application-wide Reown client object
* @type { walletKit: WalletKit, core: Core }
Expand Down
22 changes: 20 additions & 2 deletions src/sagas/modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,37 @@
* LICENSE file in the root directory of this source tree.
*/

/**
* This module handles the global modal system through sagas.
* It provides a way to show and hide modals from anywhere in the application
* through Redux actions, while keeping the actual modal context in a central place.
*/

import { takeEvery, call } from 'redux-saga/effects';
import { types } from '../actions';

let modalContext = null;

/**
* Sets the modal context that will be used to show/hide modals.
* This should be called when the application starts with the GlobalModal context.
*
* @param {Object} context - The modal context containing showModal and hideModal methods
*/
export const setModalContext = (context) => {
modalContext = context;
};

/**
* Saga that handles showing a modal through the modal context.
* It will use the provided modal context to display the modal with the given type and props.
*
* @param {Object} action - The Redux action containing the modal type and props
* @param {string} action.payload.modalType - The type of modal to show
* @param {Object} action.payload.modalProps - The props to pass to the modal
*/
function* showModal({ payload: { modalType, modalProps } }) {
console.log('Will show modal: ', modalType, modalProps);
if (modalContext) {
console.log('has modal context.', modalContext);
yield call([modalContext, modalContext.showModal], modalType, modalProps);
}
}
Expand Down
4 changes: 0 additions & 4 deletions src/sagas/reown.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import {
select,
race,
actionChannel,
delay,
} from 'redux-saga/effects';
import { eventChannel } from 'redux-saga';
import { get, values } from 'lodash';
Expand Down Expand Up @@ -114,9 +113,6 @@ function* init() {
logger: 'debug',
});

// Wait a bit to ensure all core components are initialized
yield delay(1000);

const metadata = {
name: 'Hathor',
description: 'Hathor Mobile Wallet',
Expand Down

0 comments on commit 64134bd

Please sign in to comment.