From 7049189b8fd199dcfa3df5c95d06899c06bb935d Mon Sep 17 00:00:00 2001 From: Tim Golen Date: Wed, 18 May 2022 09:56:34 -0600 Subject: [PATCH 1/2] Simplify growl is ready --- src/components/GrowlNotification/index.js | 5 +++-- src/libs/Growl.js | 10 ++++++---- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/components/GrowlNotification/index.js b/src/components/GrowlNotification/index.js index 6d7fe9f2417a..ed212fcde76d 100644 --- a/src/components/GrowlNotification/index.js +++ b/src/components/GrowlNotification/index.js @@ -12,7 +12,7 @@ import * as Expensicons from '../Icon/Expensicons'; import styles from '../../styles/styles'; import GrowlNotificationContainer from './GrowlNotificationContainer'; import CONST from '../../CONST'; -import * as Growl from '../../libs/Growl'; +import Growl, {setIsReady} from '../../libs/Growl'; const types = { [CONST.GROWL.SUCCESS]: { @@ -46,7 +46,8 @@ class GrowlNotification extends Component { } componentDidMount() { - Growl.setIsReady(); + Growl.show('test', CONST.GROWL.SUCCESS); + setIsReady(); } /** diff --git a/src/libs/Growl.js b/src/libs/Growl.js index 325a4ecd213c..3da2b7543532 100644 --- a/src/libs/Growl.js +++ b/src/libs/Growl.js @@ -1,12 +1,14 @@ import React from 'react'; import CONST from '../CONST'; -import createOnReadyTask from './createOnReadyTask'; const growlRef = React.createRef(); -const growlReadyTask = createOnReadyTask(); +let resolveIsReadyPromise; +const isReadyPromise = new Promise((resolve) => { + resolveIsReadyPromise = resolve; +}); function setIsReady() { - growlReadyTask.setIsReady(); + resolveIsReadyPromise(); } /** @@ -17,7 +19,7 @@ function setIsReady() { * @param {Number} [duration] */ function show(bodyText, type, duration = CONST.GROWL.DURATION) { - growlReadyTask.isReady().then(() => growlRef.current.show(bodyText, type, duration)); + isReadyPromise.then(() => growlRef.current.show(bodyText, type, duration)); } /** From dc27ac3a15147aa1eb42c5ff29562a4dab466064 Mon Sep 17 00:00:00 2001 From: Tim Golen Date: Wed, 18 May 2022 10:51:33 -0600 Subject: [PATCH 2/2] Remove test growl --- src/components/GrowlNotification/index.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/components/GrowlNotification/index.js b/src/components/GrowlNotification/index.js index ed212fcde76d..6d7fe9f2417a 100644 --- a/src/components/GrowlNotification/index.js +++ b/src/components/GrowlNotification/index.js @@ -12,7 +12,7 @@ import * as Expensicons from '../Icon/Expensicons'; import styles from '../../styles/styles'; import GrowlNotificationContainer from './GrowlNotificationContainer'; import CONST from '../../CONST'; -import Growl, {setIsReady} from '../../libs/Growl'; +import * as Growl from '../../libs/Growl'; const types = { [CONST.GROWL.SUCCESS]: { @@ -46,8 +46,7 @@ class GrowlNotification extends Component { } componentDidMount() { - Growl.show('test', CONST.GROWL.SUCCESS); - setIsReady(); + Growl.setIsReady(); } /**