Skip to content

Commit 15230c3

Browse files
CP-10688: set default currency on login (#2880)
1 parent 6f97ee5 commit 15230c3

File tree

5 files changed

+60
-0
lines changed

5 files changed

+60
-0
lines changed

packages/core-mobile/app/store/middleware/listener.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import { addWatchlistListeners } from 'store/watchlist/listeners'
1515
import { addAppearanceListeners } from 'store/settings/appearance/listeners'
1616
import { addUnifiedBridgeListeners } from 'store/unifiedBridge/listeners'
1717
import { AppAddListener, AppStartListening } from 'store/types'
18+
import { addCurrencyListeners } from 'store/settings/currency/listeners'
1819

1920
const listener = createListenerMiddleware({
2021
onError: (error, errorInfo) => {
@@ -53,6 +54,8 @@ addWatchlistListeners(startListening)
5354

5455
addAppearanceListeners(startListening)
5556

57+
addCurrencyListeners(startListening)
58+
5659
export const addAppListener = addListener as AppAddListener
5760

5861
export { listener }
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import { AnyAction } from '@reduxjs/toolkit'
2+
import { onLogIn } from 'store/app'
3+
import { AppListenerEffectAPI, AppStartListening } from 'store/types'
4+
import { getLocales } from 'expo-localization'
5+
import { setSelectedCurrency } from './slice'
6+
import { currencies, CurrencySymbol } from './types'
7+
8+
const handleSetDefaultCurrency = (
9+
_: AnyAction,
10+
listenerApi: AppListenerEffectAPI
11+
): void => {
12+
const locales = getLocales()
13+
const defaultCurrency = locales[0]?.currencyCode
14+
15+
const { dispatch } = listenerApi
16+
17+
const supportedCurrency =
18+
currencies.find(curr => curr.symbol === defaultCurrency)?.symbol ??
19+
CurrencySymbol.USD
20+
dispatch(setSelectedCurrency(supportedCurrency))
21+
}
22+
23+
export const addCurrencyListeners = (
24+
startListening: AppStartListening
25+
): void => {
26+
startListening({
27+
actionCreator: onLogIn,
28+
effect: handleSetDefaultCurrency
29+
})
30+
}

packages/core-mobile/ios/Podfile.lock

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,8 @@ PODS:
309309
- ExpoModulesCore
310310
- ExpoLocalAuthentication (15.0.2):
311311
- ExpoModulesCore
312+
- ExpoLocalization (16.1.5):
313+
- ExpoModulesCore
312314
- ExpoModulesCore (2.2.3):
313315
- DoubleConversion
314316
- glog
@@ -3030,6 +3032,7 @@ DEPENDENCIES:
30303032
- ExpoLinearGradient (from `../node_modules/expo-linear-gradient/ios`)
30313033
- ExpoLinking (from `../node_modules/expo-linking/ios`)
30323034
- ExpoLocalAuthentication (from `../node_modules/expo-local-authentication/ios`)
3035+
- ExpoLocalization (from `../node_modules/expo-localization/ios`)
30333036
- ExpoModulesCore (from `../node_modules/expo-modules-core`)
30343037
- ExpoSMS (from `../node_modules/expo-sms/ios`)
30353038
- ExpoVideo (from `../node_modules/expo-video/ios`)
@@ -3252,6 +3255,8 @@ EXTERNAL SOURCES:
32523255
:path: "../node_modules/expo-linking/ios"
32533256
ExpoLocalAuthentication:
32543257
:path: "../node_modules/expo-local-authentication/ios"
3258+
ExpoLocalization:
3259+
:path: "../node_modules/expo-localization/ios"
32553260
ExpoModulesCore:
32563261
:path: "../node_modules/expo-modules-core"
32573262
ExpoSMS:
@@ -3533,6 +3538,7 @@ SPEC CHECKSUMS:
35333538
ExpoLinearGradient: ee9efc5acb988b911320e964fab9b4cbdeb198c4
35343539
ExpoLinking: 0381341519ca7180a3a057d20edb1cf6a908aaf4
35353540
ExpoLocalAuthentication: 64bf2cbee456f5639d69a853684c285afc0602d8
3541+
ExpoLocalization: 7cd94f24bc3ff2f263cb4258fe1e86a97bc1ea64
35363542
ExpoModulesCore: dd965804a882f1dbb6036fceea4d912461aeaa0d
35373543
ExpoSMS: 2f90c7c780ef65c9f52b800183aab554360b34a2
35383544
ExpoVideo: 6860956b8fc77af4e69165236af5fc037a060a02

packages/core-mobile/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@
119119
"expo-linear-gradient": "14.0.2",
120120
"expo-linking": "7.0.5",
121121
"expo-local-authentication": "15.0.2",
122+
"expo-localization": "16.1.5",
122123
"expo-router": "4.0.18",
123124
"expo-sms": "13.0.1",
124125
"expo-video": "2.0.5",

yarn.lock

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,7 @@ __metadata:
337337
expo-linear-gradient: 14.0.2
338338
expo-linking: 7.0.5
339339
expo-local-authentication: 15.0.2
340+
expo-localization: 16.1.5
340341
expo-router: 4.0.18
341342
expo-sms: 13.0.1
342343
expo-video: 2.0.5
@@ -19079,6 +19080,18 @@ __metadata:
1907919080
languageName: node
1908019081
linkType: hard
1908119082

19083+
"expo-localization@npm:16.1.5":
19084+
version: 16.1.5
19085+
resolution: "expo-localization@npm:16.1.5"
19086+
dependencies:
19087+
rtl-detect: ^1.0.2
19088+
peerDependencies:
19089+
expo: "*"
19090+
react: "*"
19091+
checksum: c301e594e2a93b7e7ca278bbd4856ef23b7da1b72affaa1d7a62e54de02d949bdd23a939b7113105c1fae29317d69527e74b617fd8e666143f8211d54131fe38
19092+
languageName: node
19093+
linkType: hard
19094+
1908219095
"expo-manifests@npm:~0.15.7":
1908319096
version: 0.15.8
1908419097
resolution: "expo-manifests@npm:0.15.8"
@@ -28672,6 +28685,13 @@ react-native-webview@ava-labs/react-native-webview:
2867228685
languageName: node
2867328686
linkType: hard
2867428687

28688+
"rtl-detect@npm:^1.0.2":
28689+
version: 1.1.2
28690+
resolution: "rtl-detect@npm:1.1.2"
28691+
checksum: 4a43a1e5df0617eb86d5485640b318787d12b86acf53d840a3b2ff701ee941e95479d4e9ae97e907569ec763d1c47218cb87639bc87bcdad60a85747e5270cf0
28692+
languageName: node
28693+
linkType: hard
28694+
2867528695
"run-async@npm:^2.4.0":
2867628696
version: 2.4.1
2867728697
resolution: "run-async@npm:2.4.1"

0 commit comments

Comments
 (0)