From 2bb82baf9712c2fe8e98f54166f45f7cac83d0c1 Mon Sep 17 00:00:00 2001 From: srikanth716 <97477121+srikanth716@users.noreply.github.com> Date: Wed, 18 Oct 2023 14:00:59 +0530 Subject: [PATCH] Inji 408 error popup after maximum retries vc download (#926) * feat(INJI-408):Display error message after max retries of downloading vcs Signed-off-by: Sri Kanth Kola * feat(INJI-408):refactor error message Signed-off-by: Sri Kanth Kola * feat(INJI-408):refactor naming convention and remove empty space Signed-off-by: Sri Kanth Kola * feat(INJI-408):refactor naming convention Signed-off-by: Sri Kanth Kola --------- Signed-off-by: Sri Kanth Kola --- locales/ara.json | 4 + locales/en.json | 4 + locales/fil.json | 4 + locales/hin.json | 4 + locales/kan.json | 4 + locales/spa.json | 4 + locales/tam.json | 4 + .../ExistingMosipVCItemMachine.ts | 17 ++++- machines/vc.ts | 73 ++++++++++++++++++- screens/Home/MyVcsTab.tsx | 18 +++++ screens/Home/MyVcsTabController.ts | 10 +++ 11 files changed, 144 insertions(+), 2 deletions(-) diff --git a/locales/ara.json b/locales/ara.json index 07bb973883..237416ce7a 100644 --- a/locales/ara.json +++ b/locales/ara.json @@ -297,6 +297,10 @@ "title": "لا يوجد اتصال بالإنترنت", "message": "الرجاء التحقق من اتصالك وإعادة المحاولة" }, + "downloadLimitExpires":{ + "title": "الخطأ تحميل", + "message": "حدثت مشكلة أثناء تنزيل البطاقات التالية. حاول مرة اخرى" + } } }, "OnboardingOverlay": { diff --git a/locales/en.json b/locales/en.json index e1064f5324..a180132747 100644 --- a/locales/en.json +++ b/locales/en.json @@ -303,6 +303,10 @@ "noInternetConnection": { "title": "No internet connection", "message": "Please check your connection and retry" + }, + "downloadLimitExpires":{ + "title": "Download Error", + "message": "There was an issue downloading following cards. Please try again" } } }, diff --git a/locales/fil.json b/locales/fil.json index f9f6a32da5..dae27bd6d6 100644 --- a/locales/fil.json +++ b/locales/fil.json @@ -295,6 +295,10 @@ "noInternetConnection": { "title": "Pakisuri ang iyong koneksyon at subukang muli", "message": "Mangyaring kumonekta sa internet at subukang muli." + }, + "downloadLimitExpires":{ + "title": "Error sa Pag-download", + "message": "Nagkaroon ng isyu sa pag-download ng mga sumusunod na card. Pakisubukang muli" } } }, diff --git a/locales/hin.json b/locales/hin.json index da03e470d6..9b4cb72bc9 100644 --- a/locales/hin.json +++ b/locales/hin.json @@ -296,6 +296,10 @@ "title": "कोई इंटरनेट कनेक्शन नहीं", "message": "कृपया अपना कनेक्शन जांचें और पुनः प्रयास करें" }, + "downloadLimitExpires":{ + "title": "डाउनलोड त्रुटि", + "message": "निम्नलिखित कार्ड डाउनलोड करने में एक समस्या थी। कृपया पुन: प्रयास करें" + } } }, "OnboardingOverlay": { diff --git a/locales/kan.json b/locales/kan.json index e543cc5361..e7ba9b2020 100644 --- a/locales/kan.json +++ b/locales/kan.json @@ -293,6 +293,10 @@ "title": "ಇಂಟರ್ನೆಟ್ ಸಂಪರ್ಕವಿಲ್ಲ", "message": "ದಯವಿಟ್ಟು ನಿಮ್ಮ ಸಂಪರ್ಕವನ್ನು ಪರಿಶೀಲಿಸಿ ಮತ್ತು ಮರುಪ್ರಯತ್ನಿಸಿ" }, + "downloadLimitExpires":{ + "title": "ಡೌನ್‌ಲೋಡ್ ದೋಷ", + "message": "ಕೆಳಗಿನ ಕಾರ್ಡ್‌ಗಳನ್ನು ಡೌನ್‌ಲೋಡ್ ಮಾಡುವಲ್ಲಿ ಸಮಸ್ಯೆ ಕಂಡುಬಂದಿದೆ. ದಯವಿಟ್ಟು ಪುನಃ ಪ್ರಯತ್ನಿಸಿ" + } } }, "OnboardingOverlay": { diff --git a/locales/spa.json b/locales/spa.json index 35afb4146f..820639c392 100644 --- a/locales/spa.json +++ b/locales/spa.json @@ -206,6 +206,10 @@ "title": "Sin conexión a Internet", "message": "Por favor verifique su conexión y vuelva a intentarlo" }, + "downloadLimitExpires":{ + "title": "Error de descarga", + "message": "Hubo un problema al descargar las siguientes tarjetas. Inténtalo de nuevo" + } } }, "OnboardingOverlay": { diff --git a/locales/tam.json b/locales/tam.json index 71575ec119..6efc6e4524 100644 --- a/locales/tam.json +++ b/locales/tam.json @@ -292,6 +292,10 @@ "noInternetConnection": { "title": "இணைய இணைப்பு இல்லை", "message": "உங்கள் இணைப்பைச் சரிபார்த்து மீண்டும் முயற்சிக்கவும்" + }, + "downloadLimitExpires":{ + "title": "பதிவிறக்கப் பிழை", + "message": "பின்வரும் கார்டுகளைப் பதிவிறக்குவதில் சிக்கல் ஏற்பட்டது. தயவு செய்து மீண்டும் முயற்சிக்கவும்" } } }, diff --git a/machines/VCItemMachine/ExistingMosipVCItem/ExistingMosipVCItemMachine.ts b/machines/VCItemMachine/ExistingMosipVCItem/ExistingMosipVCItemMachine.ts index ff239ccab5..ac757f3f06 100644 --- a/machines/VCItemMachine/ExistingMosipVCItem/ExistingMosipVCItemMachine.ts +++ b/machines/VCItemMachine/ExistingMosipVCItem/ExistingMosipVCItemMachine.ts @@ -173,7 +173,10 @@ export const ExistingMosipVCItemMachine = actions: ['setMaxDownloadCount', 'setDownloadInterval'], }, onError: { - actions: log((_, event) => (event.data as Error).message), + actions: [ + log((_, event) => (event.data as Error).message), + 'sendDownloadLimitExpire', + ], target: 'checkingStatus', }, }, @@ -808,6 +811,18 @@ export const ExistingMosipVCItemMachine = }, ), + sendDownloadLimitExpire: send( + (_context, event) => { + return { + type: 'DOWNLOAD_LIMIT_EXPIRED', + vcMetadata: _context.vcMetadata, + }; + }, + { + to: context => context.serviceRefs.vc, + }, + ), + setWalletBindingError: assign({ walletBindingError: () => i18n.t(`errors.genericError`, { diff --git a/machines/vc.ts b/machines/vc.ts index 99ba645b99..59b1a31814 100644 --- a/machines/vc.ts +++ b/machines/vc.ts @@ -22,6 +22,7 @@ const model = createModel( areAllVcsDownloaded: false as boolean, walletBindingSuccess: false, tamperedVcs: [] as VCMetadata[], + downloadingFailedVcs: [] as VCMetadata[], }, { events: { @@ -52,6 +53,8 @@ const model = createModel( RESET_ARE_ALL_VCS_DOWNLOADED: () => ({}), TAMPERED_VC: (VC: VCMetadata) => ({VC}), REMOVE_TAMPERED_VCS: () => ({}), + DOWNLOAD_LIMIT_EXPIRED: (vcMetadata: VCMetadata) => ({vcMetadata}), + DELETE_VC: () => ({}), }, }, ); @@ -201,6 +204,13 @@ export const vcMachine = actions: 'setTamperedVcs', target: 'tamperedVCs', }, + DOWNLOAD_LIMIT_EXPIRED: { + actions: [ + 'removeVcFromInProgressDownlods', + 'setDownloadingFailedVcs', + ], + target: 'downloadLimitExpired', + }, }, }, tamperedVCs: { @@ -211,6 +221,25 @@ export const vcMachine = }, }, }, + downloadLimitExpired: { + on: { + DELETE_VC: { + target: 'deletingFailedVcs', + }, + }, + }, + deletingFailedVcs: { + entry: 'removeDownloadFailedVcsFromStorage', + on: { + STORE_RESPONSE: { + actions: [ + 'removeDownloadingFailedVcsFromMyVcs', + 'resetDownloadFailedVcs', + ], + target: '#vc.ready.myVcs.refreshing', + }, + }, + }, }, }, { @@ -252,6 +281,17 @@ export const vcMachine = tamperedVcs: (context, event) => [event.VC, ...context.tamperedVcs], }), + setDownloadingFailedVcs: model.assign({ + downloadingFailedVcs: (context, event) => [ + event.vcMetadata, + ...context.downloadingFailedVcs, + ], + }), + + resetDownloadFailedVcs: model.assign({ + downloadingFailedVcs: (context, event) => [], + }), + setDownloadedVc: (context, event) => { const vcUniqueId = VCMetadata.fromVC(event.vc).getVcKey(); context.vcs[vcUniqueId] = event.vc; @@ -271,7 +311,10 @@ export const vcMachine = inProgressVcDownloads: (context, event) => { let paresedInProgressList: Set = context.inProgressVcDownloads; - const removeVcRequestID = event.requestId; + const removeVcRequestID = + event.type === 'REMOVE_VC_FROM_IN_PROGRESS_DOWNLOADS' + ? event.requestId + : event.vcMetadata.requestId; paresedInProgressList.delete(removeVcRequestID); return paresedInProgressList; }, @@ -323,6 +366,26 @@ export const vcMachine = ), }), + removeDownloadingFailedVcsFromMyVcs: model.assign({ + myVcs: (context, event) => + context.myVcs.filter( + value => + !context.downloadingFailedVcs.some(item => item?.equals(value)), + ), + }), + + removeDownloadFailedVcsFromStorage: send( + context => { + return StoreEvents.REMOVE_ITEMS( + MY_VCS_STORE_KEY, + context.downloadingFailedVcs.map(m => m.getVcKey()), + ); + }, + { + to: context => context.serviceRefs.store, + }, + ), + removeTamperedVcs: model.assign({ myVcs: (context, event) => context.myVcs.filter( @@ -462,3 +525,11 @@ export function selectWalletBindingSuccess(state: State) { export function selectIsTampered(state: State) { return state.matches('tamperedVCs'); } + +export function selectIsDownloadLimitExpired(state: State) { + return state.matches('downloadLimitExpired'); +} + +export function selectDownloadingFailedVcs(state: State) { + return state.context.downloadingFailedVcs; +} diff --git a/screens/Home/MyVcsTab.tsx b/screens/Home/MyVcsTab.tsx index 01c369da0e..94899c61d1 100644 --- a/screens/Home/MyVcsTab.tsx +++ b/screens/Home/MyVcsTab.tsx @@ -77,6 +77,14 @@ export const MyVcsTab: React.FC = props => { } }, [controller.areAllVcsLoaded, controller.inProgressVcDownloads]); + let failedVCsList = []; + controller.downloadFailedVcs.forEach(vc => { + failedVCsList.push(`${vc.idType}:${vc.id}\n`); + }); + const downloadFailedVcsErrorMessage = `${t( + 'errors.downloadLimitExpires.message', + )}\n${failedVCsList}`; + return ( @@ -233,6 +241,16 @@ export const MyVcsTab: React.FC = props => { buttonText={t('common:ok')} customHeight={'auto'} /> + + + {controller.isNetworkOff && ( service.send(MyVcsTabEvents.SET_STORE_VC_ITEM_STATUS()), @@ -100,5 +109,6 @@ export function useMyVcsTab(props: HomeScreenTabProps) { settingsService.send(SettingsEvents.ACCEPT_HARDWARE_SUPPORT_NOT_EXISTS()), REMOVE_TAMPERED_VCS: () => vcService?.send(VcEvents.REMOVE_TAMPERED_VCS()), + DELETE_VC: () => vcService?.send(VcEvents.DELETE_VC()), }; }