From 1c219a24382d80d41745cf83c45c6cf476af8e61 Mon Sep 17 00:00:00 2001 From: Bartosz Grajdek Date: Thu, 7 Sep 2023 15:01:27 +0200 Subject: [PATCH 1/2] [TS migration] Migrate 'Modal.js' lib to TypeScript --- src/libs/actions/{Modal.js => Modal.ts} | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) rename src/libs/actions/{Modal.js => Modal.ts} (74%) diff --git a/src/libs/actions/Modal.js b/src/libs/actions/Modal.ts similarity index 74% rename from src/libs/actions/Modal.js rename to src/libs/actions/Modal.ts index ea3bfc351593..c5dd878ed1b7 100644 --- a/src/libs/actions/Modal.js +++ b/src/libs/actions/Modal.ts @@ -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): 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) { @@ -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): void { 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): void { Onyx.merge(ONYXKEYS.MODAL, {willAlertModalBecomeVisible: isVisible}); } From 0224d059481bd1126683ab480c3024d96b59d7e4 Mon Sep 17 00:00:00 2001 From: Bartosz Grajdek Date: Tue, 12 Sep 2023 11:18:07 +0200 Subject: [PATCH 2/2] Remove void return --- src/libs/actions/Modal.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/libs/actions/Modal.ts b/src/libs/actions/Modal.ts index c5dd878ed1b7..ff09731f59a7 100644 --- a/src/libs/actions/Modal.ts +++ b/src/libs/actions/Modal.ts @@ -7,7 +7,7 @@ let onModalClose: null | (() => void); /** * Allows other parts of the app to call modal close function */ -function setCloseModal(onClose: () => void): void { +function setCloseModal(onClose: () => void) { closeModal = onClose; } @@ -38,7 +38,7 @@ function onModalDidClose() { /** * Allows other parts of the app to know when a modal has been opened or closed */ -function setModalVisibility(isVisible: boolean): void { +function setModalVisibility(isVisible: boolean) { Onyx.merge(ONYXKEYS.MODAL, {isVisible}); } @@ -46,7 +46,7 @@ function setModalVisibility(isVisible: boolean): void { * 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. */ -function willAlertModalBecomeVisible(isVisible: boolean): void { +function willAlertModalBecomeVisible(isVisible: boolean) { Onyx.merge(ONYXKEYS.MODAL, {willAlertModalBecomeVisible: isVisible}); }