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

Delay in showing new currency when selecting a new currency #42183

Merged
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions src/libs/Navigation/Navigation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import originalGetTopmostReportId from './getTopmostReportId';
import linkingConfig from './linkingConfig';
import linkTo from './linkTo';
import navigationRef from './navigationRef';
import setNavigationActionToMicrotaskQueue from './setNavigationActionToMicrotaskQueue';
import switchPolicyID from './switchPolicyID';
import type {NavigationStateRoute, State, StateOrRoute, SwitchPolicyIDParams} from './types';

Expand Down Expand Up @@ -384,6 +385,7 @@ export default {
resetToHome,
isDisplayedInModal,
closeRHPFlow,
setNavigationActionToMicrotaskQueue,
};

export {navigationRef};
13 changes: 13 additions & 0 deletions src/libs/Navigation/setNavigationActionToMicrotaskQueue.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
export default function setNavigationActionToMicrotaskQueue(navigationAction: () => void) {
/**
* The function is used when the app needs to set a navigation action to the microtask queue, it guarantees to execute Onyx.update first, then the navigation action.
* More details - https://github.com/Expensify/App/issues/37785#issuecomment-1989056726.
*/
new Promise<void>((resolve) => {
resolve();
}).then(() => {
requestAnimationFrame(() => {
navigationAction();
});
});
}
3 changes: 2 additions & 1 deletion src/pages/iou/request/step/IOURequestStepCurrency.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ function IOURequestStepCurrency({
if (pageIndex !== 'confirm') {
IOU.setMoneyRequestCurrency(transactionID, option.currencyCode, action === CONST.IOU.ACTION.EDIT);
}
navigateBack(option.currencyCode);

Navigation.setNavigationActionToMicrotaskQueue(() => navigateBack(option.currencyCode));
};

return (
Expand Down
2 changes: 1 addition & 1 deletion src/pages/workspace/WorkspaceProfileCurrencyPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ function WorkspaceProfileCurrencyPage({policy}: WorkspaceProfileCurrencyPageProp

const onSelectCurrency = (item: CurrencyListItem) => {
Policy.updateGeneralSettings(policy?.id ?? '', policy?.name ?? '', item.currencyCode);
Navigation.goBack();
Navigation.setNavigationActionToMicrotaskQueue(Navigation.goBack);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NAB but same here. Let us add a test case for this to avoid possible regression.

};

return (
Expand Down
Loading