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

[No QA] [TS migration] Migrate 'Modal.js' lib to TypeScript #26957

Merged
Merged
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
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