Skip to content

Commit

Permalink
Merge pull request #8280 from Expensify/chiragsalian-cherry-pick-stag…
Browse files Browse the repository at this point in the history
…ing-8271

🍒 Cherry pick PR #8271 to staging 🍒
  • Loading branch information
OSBotify authored Mar 24, 2022
2 parents 6a3d1a4 + 6580103 commit 074ea0a
Show file tree
Hide file tree
Showing 9 changed files with 38 additions and 18 deletions.
4 changes: 2 additions & 2 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,8 @@ android {
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
multiDexEnabled rootProject.ext.multiDexEnabled
versionCode 1001014404
versionName "1.1.44-4"
versionCode 1001014405
versionName "1.1.44-5"
}
splits {
abi {
Expand Down
2 changes: 1 addition & 1 deletion ios/NewExpensify/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
</dict>
</array>
<key>CFBundleVersion</key>
<string>1.1.44.4</string>
<string>1.1.44.5</string>
<key>ITSAppUsesNonExemptEncryption</key>
<false/>
<key>LSApplicationQueriesSchemes</key>
Expand Down
2 changes: 1 addition & 1 deletion ios/NewExpensifyTests/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1.1.44.4</string>
<string>1.1.44.5</string>
</dict>
</plist>
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "new.expensify",
"version": "1.1.44-4",
"version": "1.1.44-5",
"author": "Expensify, Inc.",
"homepage": "https://new.expensify.com",
"description": "New Expensify is the next generation of Expensify: a reimagination of payments based atop a foundation of chat.",
Expand Down
9 changes: 7 additions & 2 deletions src/components/GrowlNotification/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +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';

const types = {
[CONST.GROWL.SUCCESS]: {
Expand All @@ -31,8 +32,8 @@ const types = {
const INACTIVE_POSITION_Y = -255;

class GrowlNotification extends Component {
constructor() {
super();
constructor(props) {
super(props);

this.state = {
bodyText: '',
Expand All @@ -44,6 +45,10 @@ class GrowlNotification extends Component {
this.fling = this.fling.bind(this);
}

componentDidMount() {
Growl.setIsReady();
}

/**
* Show the growl notification
*
Expand Down
12 changes: 3 additions & 9 deletions src/libs/ActiveClientManager/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,16 @@ import Onyx from 'react-native-onyx';
import Str from 'expensify-common/lib/str';
import ONYXKEYS from '../../ONYXKEYS';
import * as ActiveClients from '../actions/ActiveClients';
import createOnReadyTask from '../createOnReadyTask';

const clientID = Str.guid();
const maxClients = 20;

let activeClients;
let isInitialized;

// Keeps track of the ActiveClientManager's readiness in one place
// so that multiple calls of isReady resolve the same promise
const isInitializedPromise = new Promise((resolve) => {
isInitialized = resolve;
});
const [isReady, setIsReady] = createOnReadyTask();

Onyx.connect({
key: ONYXKEYS.ACTIVE_CLIENTS,
Expand All @@ -32,11 +30,7 @@ Onyx.connect({
*/
function init() {
ActiveClients.addClient(clientID)
.then(isInitialized);
}

function isReady() {
return isInitializedPromise;
.then(setIsReady);
}

/**
Expand Down
5 changes: 4 additions & 1 deletion src/libs/Growl.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import React from 'react';
import CONST from '../CONST';
import createOnReadyTask from './createOnReadyTask';

const growlRef = React.createRef();
const [isGrowlReady, setIsReady] = createOnReadyTask();

/**
* Show the growl notification
Expand All @@ -11,7 +13,7 @@ const growlRef = React.createRef();
* @param {Number} [duration]
*/
function show(bodyText, type, duration = CONST.GROWL.DURATION) {
growlRef.current.show(bodyText, type, duration);
isGrowlReady().then(() => growlRef.current.show(bodyText, type, duration));
}

/**
Expand Down Expand Up @@ -42,4 +44,5 @@ export default {

export {
growlRef,
setIsReady,
};
18 changes: 18 additions & 0 deletions src/libs/createOnReadyTask.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/**
* Helper method to create a task to track the "readiness" of something and defer any actions until after something is "ready".
*
* @example
*
* const [isSomethingReady, setIsReady] = createOnReadyTask();
* isSomethingReady().then(() => doIt());
* setIsReady(); // -> doIt() will now execute
*
* @returns {Array<Promise, Function>}
*/
export default function createOnReadyTask() {
let resolveIsReadyPromise;
const isReadyPromise = (new Promise((resolve) => {
resolveIsReadyPromise = resolve;
}));
return [() => isReadyPromise, resolveIsReadyPromise];
}

0 comments on commit 074ea0a

Please sign in to comment.