Skip to content

Commit

Permalink
Inji 408 error popup after maximum retries vc download (#926)
Browse files Browse the repository at this point in the history
* feat(INJI-408):Display error message after max retries of downloading vcs

Signed-off-by: Sri Kanth Kola <[email protected]>

* feat(INJI-408):refactor error message

Signed-off-by: Sri Kanth Kola <[email protected]>

* feat(INJI-408):refactor naming convention and remove empty space

Signed-off-by: Sri Kanth Kola <[email protected]>

* feat(INJI-408):refactor naming convention

Signed-off-by: Sri Kanth Kola <[email protected]>

---------

Signed-off-by: Sri Kanth Kola <[email protected]>
  • Loading branch information
srikanth716 authored Oct 18, 2023
1 parent ed76f21 commit 2bb82ba
Show file tree
Hide file tree
Showing 11 changed files with 144 additions and 2 deletions.
4 changes: 4 additions & 0 deletions locales/ara.json
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,10 @@
"title": "لا يوجد اتصال بالإنترنت",
"message": "الرجاء التحقق من اتصالك وإعادة المحاولة"
},
"downloadLimitExpires":{
"title": "الخطأ تحميل",
"message": "حدثت مشكلة أثناء تنزيل البطاقات التالية. حاول مرة اخرى"
}
}
},
"OnboardingOverlay": {
Expand Down
4 changes: 4 additions & 0 deletions locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
},
Expand Down
4 changes: 4 additions & 0 deletions locales/fil.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
},
Expand Down
4 changes: 4 additions & 0 deletions locales/hin.json
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,10 @@
"title": "कोई इंटरनेट कनेक्शन नहीं",
"message": "कृपया अपना कनेक्शन जांचें और पुनः प्रयास करें"
},
"downloadLimitExpires":{
"title": "डाउनलोड त्रुटि",
"message": "निम्नलिखित कार्ड डाउनलोड करने में एक समस्या थी। कृपया पुन: प्रयास करें"
}
}
},
"OnboardingOverlay": {
Expand Down
4 changes: 4 additions & 0 deletions locales/kan.json
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,10 @@
"title": "ಇಂಟರ್ನೆಟ್ ಸಂಪರ್ಕವಿಲ್ಲ",
"message": "ದಯವಿಟ್ಟು ನಿಮ್ಮ ಸಂಪರ್ಕವನ್ನು ಪರಿಶೀಲಿಸಿ ಮತ್ತು ಮರುಪ್ರಯತ್ನಿಸಿ"
},
"downloadLimitExpires":{
"title": "ಡೌನ್‌ಲೋಡ್ ದೋಷ",
"message": "ಕೆಳಗಿನ ಕಾರ್ಡ್‌ಗಳನ್ನು ಡೌನ್‌ಲೋಡ್ ಮಾಡುವಲ್ಲಿ ಸಮಸ್ಯೆ ಕಂಡುಬಂದಿದೆ. ದಯವಿಟ್ಟು ಪುನಃ ಪ್ರಯತ್ನಿಸಿ"
}
}
},
"OnboardingOverlay": {
Expand Down
4 changes: 4 additions & 0 deletions locales/spa.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
4 changes: 4 additions & 0 deletions locales/tam.json
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,10 @@
"noInternetConnection": {
"title": "இணைய இணைப்பு இல்லை",
"message": "உங்கள் இணைப்பைச் சரிபார்த்து மீண்டும் முயற்சிக்கவும்"
},
"downloadLimitExpires":{
"title": "பதிவிறக்கப் பிழை",
"message": "பின்வரும் கார்டுகளைப் பதிவிறக்குவதில் சிக்கல் ஏற்பட்டது. தயவு செய்து மீண்டும் முயற்சிக்கவும்"
}
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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',
},
},
Expand Down Expand Up @@ -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`, {
Expand Down
73 changes: 72 additions & 1 deletion machines/vc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ const model = createModel(
areAllVcsDownloaded: false as boolean,
walletBindingSuccess: false,
tamperedVcs: [] as VCMetadata[],
downloadingFailedVcs: [] as VCMetadata[],
},
{
events: {
Expand Down Expand Up @@ -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: () => ({}),
},
},
);
Expand Down Expand Up @@ -201,6 +204,13 @@ export const vcMachine =
actions: 'setTamperedVcs',
target: 'tamperedVCs',
},
DOWNLOAD_LIMIT_EXPIRED: {
actions: [
'removeVcFromInProgressDownlods',
'setDownloadingFailedVcs',
],
target: 'downloadLimitExpired',
},
},
},
tamperedVCs: {
Expand All @@ -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',
},
},
},
},
},
{
Expand Down Expand Up @@ -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;
Expand All @@ -271,7 +311,10 @@ export const vcMachine =
inProgressVcDownloads: (context, event) => {
let paresedInProgressList: Set<string> =
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;
},
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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;
}
18 changes: 18 additions & 0 deletions screens/Home/MyVcsTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,14 @@ export const MyVcsTab: React.FC<HomeScreenTabProps> = 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 (
<React.Fragment>
<Column fill style={{display: props.isVisible ? 'flex' : 'none'}}>
Expand Down Expand Up @@ -233,6 +241,16 @@ export const MyVcsTab: React.FC<HomeScreenTabProps> = props => {
buttonText={t('common:ok')}
customHeight={'auto'}
/>

<MessageOverlay
isVisible={controller.isDownloadLimitExpires}
title={t('errors.downloadLimitExpires.title')}
message={downloadFailedVcsErrorMessage}
onButtonPress={controller.DELETE_VC}
buttonText={t('common:ok')}
customHeight={'auto'}
/>

{controller.isNetworkOff && (
<Error
testID={`networkOffError`}
Expand Down
10 changes: 10 additions & 0 deletions screens/Home/MyVcsTabController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import {
selectAreAllVcsDownloaded,
selectInProgressVcDownloads,
selectIsTampered,
selectIsDownloadLimitExpired,
selectDownloadingFailedVcs,
} from '../../machines/vc';
import {
selectWalletBindingError,
Expand Down Expand Up @@ -66,6 +68,13 @@ export function useMyVcsTab(props: HomeScreenTabProps) {

isTampered: useSelector(vcService, selectIsTampered),

isDownloadLimitExpires: useSelector(
vcService,
selectIsDownloadLimitExpired,
),

downloadFailedVcs: useSelector(vcService, selectDownloadingFailedVcs),

SET_STORE_VC_ITEM_STATUS: () =>
service.send(MyVcsTabEvents.SET_STORE_VC_ITEM_STATUS()),

Expand Down Expand Up @@ -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()),
};
}

0 comments on commit 2bb82ba

Please sign in to comment.