diff --git a/ios/Podfile.lock b/ios/Podfile.lock index acc8720dafc..db9c9bff75e 100644 --- a/ios/Podfile.lock +++ b/ios/Podfile.lock @@ -1967,8 +1967,8 @@ SPEC CHECKSUMS: SocketRocket: f32cd54efbe0f095c4d7594881e52619cfe80b17 Turf: 13d1a92d969ca0311bbc26e8356cca178ce95da2 VisionCamera: 7d13aae043ffb38b224a0f725d1e23ca9c190fe7 - Yoga: e64aa65de36c0832d04e8c7bd614396c77a80047 + Yoga: 13c8ef87792450193e117976337b8527b49e8c03 PODFILE CHECKSUM: 0ccbb4f2406893c6e9f266dc1e7470dcd72885d2 -COCOAPODS: 1.13.0 +COCOAPODS: 1.14.3 diff --git a/src/components/AddressSearch/index.tsx b/src/components/AddressSearch/index.tsx index 71fde0e42b7..a5d0848de2b 100644 --- a/src/components/AddressSearch/index.tsx +++ b/src/components/AddressSearch/index.tsx @@ -6,7 +6,6 @@ import {GooglePlacesAutocomplete} from 'react-native-google-places-autocomplete' import type {GooglePlaceData, GooglePlaceDetail} from 'react-native-google-places-autocomplete'; import FullScreenLoadingIndicator from '@components/FullscreenLoadingIndicator'; import LocationErrorMessage from '@components/LocationErrorMessage'; -import type {LocationErrorCodeType} from '@components/LocationErrorMessage/types'; import TextInput from '@components/TextInput'; import useLocalize from '@hooks/useLocalize'; import useNetwork from '@hooks/useNetwork'; @@ -15,6 +14,7 @@ import useTheme from '@hooks/useTheme'; import useThemeStyles from '@hooks/useThemeStyles'; import * as ApiUtils from '@libs/ApiUtils'; import getCurrentPosition from '@libs/getCurrentPosition'; +import type {GeolocationErrorCodeType} from '@libs/getCurrentPosition/getCurrentPosition.types'; import * as GooglePlacesUtils from '@libs/GooglePlacesUtils'; import variables from '@styles/variables'; import CONST from '@src/CONST'; @@ -69,7 +69,7 @@ function AddressSearch( const [isFocused, setIsFocused] = useState(false); // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing const [searchValue, setSearchValue] = useState(value || defaultValue || ''); - const [locationErrorCode, setLocationErrorCode] = useState(null); + const [locationErrorCode, setLocationErrorCode] = useState(null); const [isFetchingCurrentLocation, setIsFetchingCurrentLocation] = useState(false); const shouldTriggerGeolocationCallbacks = useRef(true); const containerRef = useRef(null); @@ -260,7 +260,7 @@ function AddressSearch( } setIsFetchingCurrentLocation(false); - setLocationErrorCode(errorData.code as LocationErrorCodeType); + setLocationErrorCode(errorData.code); }, { maximumAge: 0, // No cache, always get fresh location info diff --git a/src/components/LocationErrorMessage/BaseLocationErrorMessage.tsx b/src/components/LocationErrorMessage/BaseLocationErrorMessage.tsx index 54f8049c6fb..33a0bba7481 100644 --- a/src/components/LocationErrorMessage/BaseLocationErrorMessage.tsx +++ b/src/components/LocationErrorMessage/BaseLocationErrorMessage.tsx @@ -12,7 +12,7 @@ import useTheme from '@hooks/useTheme'; import useThemeStyles from '@hooks/useThemeStyles'; import colors from '@styles/theme/colors'; import CONST from '@src/CONST'; -import type {LocationErrorMessageProps} from './types'; +import type LocationErrorMessageProps from './types'; type BaseLocationErrorMessageProps = LocationErrorMessageProps & { /** A callback that runs when 'allow location permission' link is pressed */ diff --git a/src/components/LocationErrorMessage/index.native.tsx b/src/components/LocationErrorMessage/index.native.tsx index b2cca9e4423..7936fff73c0 100644 --- a/src/components/LocationErrorMessage/index.native.tsx +++ b/src/components/LocationErrorMessage/index.native.tsx @@ -1,7 +1,7 @@ import React from 'react'; import {Linking} from 'react-native'; import BaseLocationErrorMessage from './BaseLocationErrorMessage'; -import type {LocationErrorMessageProps} from './types'; +import type LocationErrorMessageProps from './types'; /** Opens app level settings from the native system settings */ const openAppSettings = () => { diff --git a/src/components/LocationErrorMessage/index.tsx b/src/components/LocationErrorMessage/index.tsx index 850cdf3a45e..193d38069d6 100644 --- a/src/components/LocationErrorMessage/index.tsx +++ b/src/components/LocationErrorMessage/index.tsx @@ -2,7 +2,7 @@ import React from 'react'; import {Linking} from 'react-native'; import CONST from '@src/CONST'; import BaseLocationErrorMessage from './BaseLocationErrorMessage'; -import type {LocationErrorMessageProps} from './types'; +import type LocationErrorMessageProps from './types'; /** Opens expensify help site in a new browser tab */ const navigateToExpensifyHelpSite = () => { diff --git a/src/components/LocationErrorMessage/types.ts b/src/components/LocationErrorMessage/types.ts index 0b7ee4ceaf9..27aa89d07ed 100644 --- a/src/components/LocationErrorMessage/types.ts +++ b/src/components/LocationErrorMessage/types.ts @@ -1,4 +1,4 @@ -type LocationErrorCodeType = -1 | 1 | 2 | 3 | null; +import type {GeolocationErrorCodeType} from '@libs/getCurrentPosition/getCurrentPosition.types'; type LocationErrorMessageProps = { /** A callback that runs when close icon is pressed */ @@ -11,7 +11,7 @@ type LocationErrorMessageProps = { * - code 2 = location is unavailable or there is some connection issue * - code 3 = location fetch timeout */ - locationErrorCode?: LocationErrorCodeType; + locationErrorCode?: GeolocationErrorCodeType | null; }; -export type {LocationErrorMessageProps, LocationErrorCodeType}; +export default LocationErrorMessageProps; diff --git a/src/libs/getCurrentPosition/getCurrentPosition.types.ts b/src/libs/getCurrentPosition/getCurrentPosition.types.ts index 792f51ceba7..612db23cf0c 100644 --- a/src/libs/getCurrentPosition/getCurrentPosition.types.ts +++ b/src/libs/getCurrentPosition/getCurrentPosition.types.ts @@ -1,3 +1,5 @@ +import type {ValueOf} from 'type-fest'; + type GeolocationSuccessCallback = (position: { coords: { latitude: number; @@ -11,8 +13,10 @@ type GeolocationSuccessCallback = (position: { timestamp: number; }) => void; +type GeolocationErrorCodeType = ValueOf; + type GeolocationErrorCallback = (error: { - code: (typeof GeolocationErrorCode)[keyof typeof GeolocationErrorCode]; + code: GeolocationErrorCodeType; message: string; PERMISSION_DENIED: typeof GeolocationErrorCode.PERMISSION_DENIED; POSITION_UNAVAILABLE: typeof GeolocationErrorCode.POSITION_UNAVAILABLE; @@ -51,4 +55,4 @@ type GetCurrentPosition = (success: GeolocationSuccessCallback, error: Geolocati export {GeolocationErrorCode}; -export type {GeolocationSuccessCallback, GeolocationErrorCallback, GeolocationOptions, GetCurrentPosition}; +export type {GeolocationSuccessCallback, GeolocationErrorCallback, GeolocationOptions, GetCurrentPosition, GeolocationErrorCodeType};