Skip to content

Commit

Permalink
added in app review count to dev screen
Browse files Browse the repository at this point in the history
  • Loading branch information
cadibemma committed Oct 6, 2024
1 parent faacbf0 commit 3256457
Showing 1 changed file with 16 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { useTranslation } from 'react-i18next'
import { useSelector } from 'react-redux'

import AsyncStorage from '@react-native-async-storage/async-storage'
import { useFocusEffect } from '@react-navigation/native'
import { StackScreenProps } from '@react-navigation/stack'

import { Button } from '@department-of-veterans-affairs/mobile-component-library'
Expand Down Expand Up @@ -37,7 +38,7 @@ import {
setVersionSkipped,
} from 'utils/homeScreenAlerts'
import { useAlert, useAppDispatch, useRouteNavigation, useTheme } from 'utils/hooks'
import { resetReviewActionCount } from 'utils/inAppReviews'
import { STORAGE_REVIEW_EVENT_KEY, resetReviewActionCount } from 'utils/inAppReviews'

type DeveloperScreenSettingsScreenProps = StackScreenProps<HomeStackParamList, 'Developer'>

Expand All @@ -56,6 +57,7 @@ function DeveloperScreen({ navigation }: DeveloperScreenSettingsScreenProps) {
const [skippedVersion, setSkippedVersionHomeScreen] = useState<string>()
const [whatsNewSkippedVersion, setWhatsNewSkippedVersionHomeScreen] = useState<string>()
const [storeVersion, setStoreVersionScreen] = useState<string>()
const [reviewCount, setReviewCount] = useState<string>()
const componentMounted = useRef(true)

async function checkEncourageUpdateLocalVersion() {
Expand Down Expand Up @@ -100,6 +102,12 @@ function DeveloperScreen({ navigation }: DeveloperScreenSettingsScreenProps) {
componentMounted.current = false
}
}, [])

useFocusEffect(
React.useCallback(() => {
getAsyncStoredData(STORAGE_REVIEW_EVENT_KEY, setReviewCount)
}, []),
)
// helper function for anything saved in AsyncStorage
const getAsyncStoredData = async (key: string, setStateFun: (val: string) => void) => {
const asyncVal = (await AsyncStorage.getItem(key)) || ''
Expand Down Expand Up @@ -141,6 +149,7 @@ function DeveloperScreen({ navigation }: DeveloperScreenSettingsScreenProps) {
const resetInAppReview = async () => {
try {
await resetReviewActionCount()
getAsyncStoredData(STORAGE_REVIEW_EVENT_KEY, setReviewCount)
showSnackBar('In app review actions reset', dispatch, undefined, true, false, true)
} catch {
showSnackBar('Failed to reset in app review actions', dispatch, resetInAppReview, false, true)
Expand Down Expand Up @@ -185,6 +194,12 @@ function DeveloperScreen({ navigation }: DeveloperScreenSettingsScreenProps) {
<Box>
<TextArea>
<Button onPress={resetInAppReview} label={'Reset in-app review actions'} />
<Box mt={theme.dimensions.condensedMarginBetween} flexDirection="row" alignItems="flex-end">
<TextView variant={'MobileBody'}>In-App Review Count:</TextView>
<TextView ml={theme.dimensions.standardMarginBetween}>
{reviewCount ? parseInt(reviewCount, 10) : 0}
</TextView>
</Box>
</TextArea>
</Box>
<Box>
Expand Down

0 comments on commit 3256457

Please sign in to comment.