Skip to content

CP-10688: set default currency on login #2880

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

Merged
merged 9 commits into from
Jun 6, 2025
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
3 changes: 3 additions & 0 deletions packages/core-mobile/app/store/middleware/listener.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { addWatchlistListeners } from 'store/watchlist/listeners'
import { addAppearanceListeners } from 'store/settings/appearance/listeners'
import { addUnifiedBridgeListeners } from 'store/unifiedBridge/listeners'
import { AppAddListener, AppStartListening } from 'store/types'
import { addCurrencyListeners } from 'store/settings/currency/listeners'

const listener = createListenerMiddleware({
onError: (error, errorInfo) => {
Expand Down Expand Up @@ -53,6 +54,8 @@ addWatchlistListeners(startListening)

addAppearanceListeners(startListening)

addCurrencyListeners(startListening)

export const addAppListener = addListener as AppAddListener

export { listener }
30 changes: 30 additions & 0 deletions packages/core-mobile/app/store/settings/currency/listeners.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { AnyAction } from '@reduxjs/toolkit'
import { onLogIn } from 'store/app'
import { AppListenerEffectAPI, AppStartListening } from 'store/types'
import { getLocales } from 'expo-localization'
import { setSelectedCurrency } from './slice'
import { currencies, CurrencySymbol } from './types'

const handleSetDefaultCurrency = (
_: AnyAction,
listenerApi: AppListenerEffectAPI
): void => {
const locales = getLocales()
const defaultCurrency = locales[0]?.currencyCode

const { dispatch } = listenerApi

const supportedCurrency =
currencies.find(curr => curr.symbol === defaultCurrency)?.symbol ??
CurrencySymbol.USD
dispatch(setSelectedCurrency(supportedCurrency))
}

export const addCurrencyListeners = (
startListening: AppStartListening
): void => {
startListening({
actionCreator: onLogIn,
effect: handleSetDefaultCurrency
})
}
6 changes: 6 additions & 0 deletions packages/core-mobile/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,8 @@ PODS:
- ExpoModulesCore
- ExpoLocalAuthentication (15.0.2):
- ExpoModulesCore
- ExpoLocalization (16.1.5):
- ExpoModulesCore
- ExpoModulesCore (2.2.3):
- DoubleConversion
- glog
Expand Down Expand Up @@ -3030,6 +3032,7 @@ DEPENDENCIES:
- ExpoLinearGradient (from `../node_modules/expo-linear-gradient/ios`)
- ExpoLinking (from `../node_modules/expo-linking/ios`)
- ExpoLocalAuthentication (from `../node_modules/expo-local-authentication/ios`)
- ExpoLocalization (from `../node_modules/expo-localization/ios`)
- ExpoModulesCore (from `../node_modules/expo-modules-core`)
- ExpoSMS (from `../node_modules/expo-sms/ios`)
- ExpoVideo (from `../node_modules/expo-video/ios`)
Expand Down Expand Up @@ -3252,6 +3255,8 @@ EXTERNAL SOURCES:
:path: "../node_modules/expo-linking/ios"
ExpoLocalAuthentication:
:path: "../node_modules/expo-local-authentication/ios"
ExpoLocalization:
:path: "../node_modules/expo-localization/ios"
ExpoModulesCore:
:path: "../node_modules/expo-modules-core"
ExpoSMS:
Expand Down Expand Up @@ -3533,6 +3538,7 @@ SPEC CHECKSUMS:
ExpoLinearGradient: ee9efc5acb988b911320e964fab9b4cbdeb198c4
ExpoLinking: 0381341519ca7180a3a057d20edb1cf6a908aaf4
ExpoLocalAuthentication: 64bf2cbee456f5639d69a853684c285afc0602d8
ExpoLocalization: 7cd94f24bc3ff2f263cb4258fe1e86a97bc1ea64
ExpoModulesCore: dd965804a882f1dbb6036fceea4d912461aeaa0d
ExpoSMS: 2f90c7c780ef65c9f52b800183aab554360b34a2
ExpoVideo: 6860956b8fc77af4e69165236af5fc037a060a02
Expand Down
1 change: 1 addition & 0 deletions packages/core-mobile/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@
"expo-linear-gradient": "14.0.2",
"expo-linking": "7.0.5",
"expo-local-authentication": "15.0.2",
"expo-localization": "16.1.5",
"expo-router": "4.0.18",
"expo-sms": "13.0.1",
"expo-video": "2.0.5",
Expand Down
20 changes: 20 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,7 @@ __metadata:
expo-linear-gradient: 14.0.2
expo-linking: 7.0.5
expo-local-authentication: 15.0.2
expo-localization: 16.1.5
expo-router: 4.0.18
expo-sms: 13.0.1
expo-video: 2.0.5
Expand Down Expand Up @@ -19079,6 +19080,18 @@ __metadata:
languageName: node
linkType: hard

"expo-localization@npm:16.1.5":
version: 16.1.5
resolution: "expo-localization@npm:16.1.5"
dependencies:
rtl-detect: ^1.0.2
peerDependencies:
expo: "*"
react: "*"
checksum: c301e594e2a93b7e7ca278bbd4856ef23b7da1b72affaa1d7a62e54de02d949bdd23a939b7113105c1fae29317d69527e74b617fd8e666143f8211d54131fe38
languageName: node
linkType: hard

"expo-manifests@npm:~0.15.7":
version: 0.15.8
resolution: "expo-manifests@npm:0.15.8"
Expand Down Expand Up @@ -28672,6 +28685,13 @@ react-native-webview@ava-labs/react-native-webview:
languageName: node
linkType: hard

"rtl-detect@npm:^1.0.2":
version: 1.1.2
resolution: "rtl-detect@npm:1.1.2"
checksum: 4a43a1e5df0617eb86d5485640b318787d12b86acf53d840a3b2ff701ee941e95479d4e9ae97e907569ec763d1c47218cb87639bc87bcdad60a85747e5270cf0
languageName: node
linkType: hard

"run-async@npm:^2.4.0":
version: 2.4.1
resolution: "run-async@npm:2.4.1"
Expand Down
Loading