From 8a90e6e3359fc6099d74e8d19fdd1f096408979b Mon Sep 17 00:00:00 2001 From: Alexander T Date: Fri, 14 Sep 2018 18:32:17 +0300 Subject: [PATCH] Simplify isPopupDisplayed, isModalDisplayed (#813) --- src/native-common/FrontLayerViewManager.tsx | 22 ++++++--------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/src/native-common/FrontLayerViewManager.tsx b/src/native-common/FrontLayerViewManager.tsx index 471063b4..34c58e8b 100644 --- a/src/native-common/FrontLayerViewManager.tsx +++ b/src/native-common/FrontLayerViewManager.tsx @@ -54,13 +54,9 @@ export class FrontLayerViewManager { public isModalDisplayed(modalId?: string) : boolean { if (modalId) { return this._findIndexOfModal(modalId) !== -1; - } else { - if (this._overlayStack.length > 0) { - const modals = _.filter(this._overlayStack, iter => (iter instanceof ModalStackContext)); - return modals.length > 0; - } - return false; } + + return this._overlayStack.some(iter => iter instanceof ModalStackContext); } public dismissModal(modalId: string): void { @@ -79,8 +75,7 @@ export class FrontLayerViewManager { } } - public showPopup( - popupOptions: Types.PopupOptions, popupId: string, delay?: number): boolean { + public showPopup(popupOptions: Types.PopupOptions, popupId: string, delay?: number): boolean { const index = this._findIndexOfPopup(popupId); if (index === -1) { const nodeHandle = RN.findNodeHandle(popupOptions.getAnchor()); @@ -284,17 +279,12 @@ export class FrontLayerViewManager { return this._overlayStack.length === 0 ? null : _.last(this._overlayStack); } - isPopupDisplayed(popupId?: string): boolean { + public isPopupDisplayed(popupId?: string): boolean { if (popupId) { return this._findIndexOfPopup(popupId) !== -1; - } else { - if (this._overlayStack.length > 0) { - const popups = _.filter(this._overlayStack, iter => (iter instanceof PopupStackContext)); - return popups.length > 0; - } - - return false; } + + return this._overlayStack.some(iter => iter instanceof PopupStackContext); } }