diff --git a/components/BannerNotificationContainer.tsx b/components/BannerNotificationContainer.tsx index b6e56cbe..fdecf02a 100644 --- a/components/BannerNotificationContainer.tsx +++ b/components/BannerNotificationContainer.tsx @@ -122,6 +122,16 @@ export const BannerNotificationContainer: React.FC< testId={'downloadingVcFailedPopup'} /> )} + + {bannerNotificationController.isDownloadingSuccess && ( + + )} ); }; diff --git a/components/BannerNotificationController.tsx b/components/BannerNotificationController.tsx index 5e0dd5e2..cf5db6a4 100644 --- a/components/BannerNotificationController.tsx +++ b/components/BannerNotificationController.tsx @@ -9,6 +9,7 @@ import {GlobalContext} from '../shared/GlobalContext'; import {VcMetaEvents} from '../machines/VerifiableCredential/VCMetaMachine/VCMetaMachine'; import { selectIsDownloadingFailed, + selectIsDownloadingSuccess, selectWalletBindingSuccess, } from '../machines/VerifiableCredential/VCMetaMachine/VCMetaSelectors'; import {selectVerificationStatus} from '../machines/VerifiableCredential/VCItemMachine/VCItemSelectors'; @@ -24,6 +25,7 @@ export const UseBannerNotification = () => { isPasscodeUnlock: useSelector(settingsService, selectIsPasscodeUnlock), isBiometricUnlock: useSelector(settingsService, selectIsBiometricUnlock), + isDownloadingSuccess: useSelector(vcMetaService, selectIsDownloadingSuccess), isDownloadingFailed: useSelector(vcMetaService, selectIsDownloadingFailed), DISMISS: () => { settingsService.send(SettingsEvents.DISMISS()); @@ -35,5 +37,8 @@ export const UseBannerNotification = () => { RESET_DOWNLOADING_FAILED: () => { vcMetaService.send(VcMetaEvents.RESET_DOWNLOADING_FAILED()); }, + RESET_DOWNLOADING_SUCCESS: () => { + vcMetaService.send(VcMetaEvents.RESET_DOWNLOADING_SUCCESS()); + }, }; }; diff --git a/locales/en.json b/locales/en.json index 5d5e60c7..e1db4e24 100644 --- a/locales/en.json +++ b/locales/en.json @@ -377,6 +377,7 @@ "generateVcFABDescription": "Tap on \"+\" below to download your card", "downloadCard": "Download Card", "downloadingYourCard": "Downloading your card, this can take upto 5 minutes", + "downloadingVcSuccess":"Your Card has been downloaded successfully", "downloadingVcFailed": "Sorry! Due to technical error we are unable to download your card now. Please try again later.", "activated": "Credentials are enabled for online authentication.", "noCardsTitle": "No Cards Found!", diff --git a/machines/VerifiableCredential/VCMetaMachine/VCMetaActions.ts b/machines/VerifiableCredential/VCMetaMachine/VCMetaActions.ts index bf80bbde..d2ee01ab 100644 --- a/machines/VerifiableCredential/VCMetaMachine/VCMetaActions.ts +++ b/machines/VerifiableCredential/VCMetaMachine/VCMetaActions.ts @@ -220,6 +220,13 @@ export const VCMetaActions = (model: any) => { resetDownloadCreadentialsFailed: model.assign({ DownloadingCredentialsFailed: () => false, }), + setDownloadCredentialsSuccess: model.assign({ + DownloadingCredentialsSuccess: () => true + + }), + resetDownloadCredentialsSuccess: model.assign({ + DownloadingCredentialsSuccess: () => false, + }), }; }; diff --git a/machines/VerifiableCredential/VCMetaMachine/VCMetaEvents.ts b/machines/VerifiableCredential/VCMetaMachine/VCMetaEvents.ts index 37267aca..8233bfa6 100644 --- a/machines/VerifiableCredential/VCMetaMachine/VCMetaEvents.ts +++ b/machines/VerifiableCredential/VCMetaMachine/VCMetaEvents.ts @@ -44,4 +44,5 @@ export const VcMetaEvents = { }), VC_DOWNLOADING_FAILED: () => ({}), RESET_DOWNLOADING_FAILED: () => ({}), + RESET_DOWNLOADING_SUCCESS: () => ({}), }; diff --git a/machines/VerifiableCredential/VCMetaMachine/VCMetaMachine.ts b/machines/VerifiableCredential/VCMetaMachine/VCMetaMachine.ts index 7483297f..30f5b003 100644 --- a/machines/VerifiableCredential/VCMetaMachine/VCMetaMachine.ts +++ b/machines/VerifiableCredential/VCMetaMachine/VCMetaMachine.ts @@ -25,6 +25,9 @@ export const vcMetaMachine = VC_DOWNLOADING_FAILED: { actions: 'setDownloadCreadentialsFailed', }, + RESET_DOWNLOADING_SUCCESS:{ + actions: 'resetDownloadCredentialsSuccess' + }, RESET_DOWNLOADING_FAILED: { actions: 'resetDownloadCreadentialsFailed', }, @@ -115,7 +118,7 @@ export const vcMetaMachine = actions: ['updateMyVcsMetadata', 'setUpdatedVcMetadatas'], }, VC_DOWNLOADED: { - actions: 'setDownloadedVc', + actions: ['setDownloadCredentialsSuccess','setDownloadedVc',] }, ADD_VC_TO_IN_PROGRESS_DOWNLOADS: { actions: 'addVcToInProgressDownloads', diff --git a/machines/VerifiableCredential/VCMetaMachine/VCMetaMachine.typegen.ts b/machines/VerifiableCredential/VCMetaMachine/VCMetaMachine.typegen.ts index c4331a6b..30b972a0 100644 --- a/machines/VerifiableCredential/VCMetaMachine/VCMetaMachine.typegen.ts +++ b/machines/VerifiableCredential/VCMetaMachine/VCMetaMachine.typegen.ts @@ -11,7 +11,7 @@ "isUserSignedAlready": "done.invoke.vcMeta.ready.tamperedVCs.triggerAutoBackupForTamperedVcDeletion:invocation[0]"; }; missingImplementations: { - actions: "addVcToInProgressDownloads" | "getVcItemResponse" | "loadMyVcs" | "loadReceivedVcs" | "logTamperedVCsremoved" | "prependToMyVcsMetadata" | "removeDownloadFailedVcsFromStorage" | "removeDownloadingFailedVcsFromMyVcs" | "removeVcFromInProgressDownlods" | "removeVcFromMyVcsMetadata" | "resetDownloadCreadentialsFailed" | "resetDownloadFailedVcs" | "resetInProgressVcsDownloaded" | "resetTamperedVcs" | "resetVerificationErrorMessage" | "resetVerificationStatus" | "resetWalletBindingSuccess" | "sendBackupEvent" | "setDownloadCreadentialsFailed" | "setDownloadedVc" | "setDownloadingFailedVcs" | "setMyVcs" | "setReceivedVcs" | "setUpdatedVcMetadatas" | "setVerificationErrorMessage" | "setVerificationStatus" | "setWalletBindingSuccess" | "updateMyVcsMetadata"; + actions: "addVcToInProgressDownloads" | "getVcItemResponse" | "loadMyVcs" | "loadReceivedVcs" | "logTamperedVCsremoved" | "prependToMyVcsMetadata" | "removeDownloadFailedVcsFromStorage" | "removeDownloadingFailedVcsFromMyVcs" | "removeVcFromInProgressDownlods" | "removeVcFromMyVcsMetadata" | "resetDownloadCreadentialsFailed" | "resetDownloadCredentialsSuccess" | "resetDownloadFailedVcs" | "resetInProgressVcsDownloaded" | "resetTamperedVcs" | "resetVerificationErrorMessage" | "resetVerificationStatus" | "resetWalletBindingSuccess" | "sendBackupEvent" | "setDownloadCreadentialsFailed" | "setDownloadCredentialsSuccess" | "setDownloadedVc" | "setDownloadingFailedVcs" | "setMyVcs" | "setReceivedVcs" | "setUpdatedVcMetadatas" | "setVerificationErrorMessage" | "setVerificationStatus" | "setWalletBindingSuccess" | "updateMyVcsMetadata"; delays: never; guards: "isAnyVcTampered" | "isSignedIn"; services: "isUserSignedAlready"; @@ -28,6 +28,7 @@ "removeVcFromInProgressDownlods": "DOWNLOAD_LIMIT_EXPIRED" | "REMOVE_VC_FROM_IN_PROGRESS_DOWNLOADS" | "VERIFY_VC_FAILED"; "removeVcFromMyVcsMetadata": "REMOVE_VC_FROM_CONTEXT"; "resetDownloadCreadentialsFailed": "RESET_DOWNLOADING_FAILED"; +"resetDownloadCredentialsSuccess": "RESET_DOWNLOADING_SUCCESS"; "resetDownloadFailedVcs": "STORE_RESPONSE"; "resetInProgressVcsDownloaded": "RESET_IN_PROGRESS_VCS_DOWNLOADED"; "resetTamperedVcs": "REMOVE_TAMPERED_VCS"; @@ -36,6 +37,7 @@ "resetWalletBindingSuccess": "RESET_WALLET_BINDING_SUCCESS"; "sendBackupEvent": "done.invoke.vcMeta.ready.tamperedVCs.triggerAutoBackupForTamperedVcDeletion:invocation[0]"; "setDownloadCreadentialsFailed": "VC_DOWNLOADING_FAILED"; +"setDownloadCredentialsSuccess": "VC_DOWNLOADED"; "setDownloadedVc": "VC_DOWNLOADED"; "setDownloadingFailedVcs": "DOWNLOAD_LIMIT_EXPIRED"; "setMyVcs": "STORE_RESPONSE"; diff --git a/machines/VerifiableCredential/VCMetaMachine/VCMetaModel.ts b/machines/VerifiableCredential/VCMetaMachine/VCMetaModel.ts index cc199e0a..0e501b1f 100644 --- a/machines/VerifiableCredential/VCMetaMachine/VCMetaModel.ts +++ b/machines/VerifiableCredential/VCMetaMachine/VCMetaModel.ts @@ -20,6 +20,7 @@ export const VCMetamodel = createModel( verificationErrorMessage: '' as string, verificationStatus: null as vcVerificationBannerDetails | null, DownloadingCredentialsFailed: false, + DownloadingCredentialsSuccess: false }, { events: VcMetaEvents, diff --git a/machines/VerifiableCredential/VCMetaMachine/VCMetaSelectors.ts b/machines/VerifiableCredential/VCMetaMachine/VCMetaSelectors.ts index 2f89407a..8fc9e2fc 100644 --- a/machines/VerifiableCredential/VCMetaMachine/VCMetaSelectors.ts +++ b/machines/VerifiableCredential/VCMetaMachine/VCMetaSelectors.ts @@ -87,3 +87,7 @@ export function selectVerificationErrorMessage(state: State) { export function selectIsDownloadingFailed(state: State) { return state.context.DownloadingCredentialsFailed; } + +export function selectIsDownloadingSuccess(state: State) { + return state.context.DownloadingCredentialsSuccess; +} diff --git a/shared/api.ts b/shared/api.ts index 7b2b3f0c..b8836d52 100644 --- a/shared/api.ts +++ b/shared/api.ts @@ -15,6 +15,7 @@ import { sendImpressionEvent, } from './telemetry/TelemetryUtils'; import {TelemetryConstants} from './telemetry/TelemetryConstants'; +import NetInfo, {NetInfoState} from '@react-native-community/netinfo'; export const API_URLS: ApiUrls = { trustedVerifiersList: { @@ -257,9 +258,10 @@ async function generateCacheAPIFunctionWithAPIPreference( }`); console.log(error); - - const response = await getItem(cacheKey, null, ''); - + var response=null; + if(!(await NetInfo.fetch()).isConnected){ + response = await getItem(cacheKey, null, ''); + } if (response) { return response; } else {