Skip to content

Commit

Permalink
Merge pull request #26957 from software-mansion-labs/ts-migration/mod…
Browse files Browse the repository at this point in the history
…al-lib

[No QA] [TS migration] Migrate 'Modal.js' lib to TypeScript
  • Loading branch information
chiragsalian authored Sep 14, 2023
2 parents 7f97bed + 0224d05 commit 39d0f01
Showing 1 changed file with 6 additions and 15 deletions.
21 changes: 6 additions & 15 deletions src/libs/actions/Modal.js → src/libs/actions/Modal.ts
Original file line number Diff line number Diff line change
@@ -1,25 +1,20 @@
import Onyx from 'react-native-onyx';
import ONYXKEYS from '../../ONYXKEYS';

let closeModal;
let onModalClose;
let closeModal: (isNavigating: boolean) => void;
let onModalClose: null | (() => void);

/**
* Allows other parts of the app to call modal close function
*
* @param {Function} [onClose]
*/
function setCloseModal(onClose) {
function setCloseModal(onClose: () => void) {
closeModal = onClose;
}

/**
* Close modal in other parts of the app
*
* @param {Function} [onModalCloseCallback]
* @param {Boolean} isNavigating
*/
function close(onModalCloseCallback, isNavigating = true) {
function close(onModalCloseCallback: () => void, isNavigating = true) {
if (!closeModal) {
// If modal is already closed, no need to wait for modal close. So immediately call callback.
if (onModalCloseCallback) {
Expand All @@ -42,20 +37,16 @@ function onModalDidClose() {

/**
* Allows other parts of the app to know when a modal has been opened or closed
*
* @param {Boolean} isVisible
*/
function setModalVisibility(isVisible) {
function setModalVisibility(isVisible: boolean) {
Onyx.merge(ONYXKEYS.MODAL, {isVisible});
}

/**
* Allows other parts of app to know that an alert modal is about to open.
* This will trigger as soon as a modal is opened but not yet visible while animation is running.
*
* @param {Boolean} isVisible
*/
function willAlertModalBecomeVisible(isVisible) {
function willAlertModalBecomeVisible(isVisible: boolean) {
Onyx.merge(ONYXKEYS.MODAL, {willAlertModalBecomeVisible: isVisible});
}

Expand Down

0 comments on commit 39d0f01

Please sign in to comment.