Skip to content

Commit

Permalink
feat(mosip#625):[Tilak/Adityan] Add a new overlay message for sql dat…
Browse files Browse the repository at this point in the history
…a full error
  • Loading branch information
tilak-puli committed Mar 14, 2023
1 parent 7248718 commit 7544c33
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 9 deletions.
8 changes: 6 additions & 2 deletions locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,12 @@
"goToReceivedVCTab": "View Received {{vcLabel}}",
"errors": {
"savingFailed": {
"title": "Failed to save {{vcLabel}}",
"message": "Something went wrong while saving {{vcLabel}} to the store."
"title": "Failed to save {{vcLabelSingular}}",
"message": "Something went wrong while saving {{vcLabelSingular}} to the store."
},
"sqlFullError": {
"title": "Failed to save {{vcLabelPlural}}",
"message": "No more {{vcLabelPlural}} can be received or saved as App Data is full."
}
}
},
Expand Down
12 changes: 11 additions & 1 deletion machines/openIdBle/request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ const model = createModel(
senderInfo: {} as DeviceInfo,
receiverInfo: {} as DeviceInfo,
incomingVc: {} as VC,
storeError: null as Error,
connectionParams: '',
loggers: [] as EmitterSubscription[],
sharingProtocol: (Platform.OS === 'ios'
Expand Down Expand Up @@ -67,7 +68,7 @@ const model = createModel(
BLUETOOTH_DISABLED: () => ({}),
STORE_READY: () => ({}),
STORE_RESPONSE: (response: unknown) => ({ response }),
STORE_ERROR: () => ({}),
STORE_ERROR: (error: Error) => ({ error }),
RECEIVE_DEVICE_INFO: (info: DeviceInfo) => ({ info }),
RECEIVED_VCS_UPDATED: () => ({}),
VC_RESPONSE: (response: unknown) => ({ response }),
Expand Down Expand Up @@ -385,6 +386,7 @@ export const requestMachine =
},
on: {
STORE_ERROR: {
actions: 'setStoringError',
target: '#request.reviewing.savingFailed',
},
},
Expand Down Expand Up @@ -537,6 +539,10 @@ export const requestMachine =
},
}),

setStoringError: assign({
storeError: (_context, event) => event.error,
}),

registerLoggers: assign({
loggers: () => {
if (__DEV__) {
Expand Down Expand Up @@ -908,6 +914,10 @@ export function selectIsSavingFailedIdle(state: State) {
return state.matches('reviewing.savingFailed.idle');
}

export function selectStoreError(state: State) {
return state.context.storeError;
}

export function selectIsRejected(state: State) {
return state.matches('reviewing.rejected');
}
Expand Down
1 change: 1 addition & 0 deletions machines/openIdBle/request.typegen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ export interface Typegen0 {
setReceiveLogTypeVerified: 'FACE_VALID';
setReceiverInfo: 'RECEIVE_DEVICE_INFO';
setSenderInfo: 'EXCHANGE_DONE';
setStoringError: 'STORE_ERROR';
storeVc: 'STORE_RESPONSE';
switchProtocol: 'SWITCH_PROTOCOL';
};
Expand Down
8 changes: 6 additions & 2 deletions screens/Request/ReceiveVcScreen.strings.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,12 @@
"goToReceivedVCTab": "View Received {{vcLabel}}",
"errors": {
"savingFailed": {
"title": "Failed to save {{vcLabel}}",
"message": "Something went wrong while saving {{vcLabel}} to the store."
"title": "Failed to save {{vcLabelSingular}}",
"message": "Something went wrong while saving {{vcLabelSingular}} to the store."
},
"sqlFullError": {
"title": "Failed to save {{vcLabelPlural}}",
"message": "No more {{vcLabelPlural}} can be received or saved as App Data is full."
}
}
}
17 changes: 13 additions & 4 deletions screens/Request/ReceiveVcScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@ export const ReceiveVcScreen: React.FC = () => {
const savingOverlayVisible = useOverlayVisibleAfterTimeout(
controller.isAccepting
);
let storeErrorTranslationPath = 'errors.savingFailed';
const isSQLFullError =
controller.storeError?.message?.match('SQLITE_FULL') != null;

if (isSQLFullError) {
storeErrorTranslationPath = 'errors.sqlFullError';
}

return (
<React.Fragment>
Expand Down Expand Up @@ -117,11 +124,13 @@ export const ReceiveVcScreen: React.FC = () => {

<MessageOverlay
isVisible={controller.isSavingFailedIdle}
title={t('errors.savingFailed.title', {
vcLabel: controller.vcLabel.singular,
title={t(storeErrorTranslationPath + '.title', {
vcLabelSingular: controller.vcLabel.singular,
vcLabelPlural: controller.vcLabel.plural,
})}
message={t('errors.savingFailed.message', {
vcLabel: controller.vcLabel.singular,
message={t(storeErrorTranslationPath + '.message', {
vcLabelSingular: controller.vcLabel.singular,
vcLabelPlural: controller.vcLabel.plural,
})}
onBackdropPress={controller.DISMISS}
/>
Expand Down
3 changes: 3 additions & 0 deletions screens/Request/ReceiveVcScreenController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { GlobalContext } from '../../shared/GlobalContext';
import {
selectIsAccepting,
selectIsSavingFailedIdle,
selectStoreError,
} from '../../machines/openIdBle/request';

export function useReceiveVcScreen() {
Expand All @@ -33,6 +34,8 @@ export function useReceiveVcScreen() {
isVerifyingIdentity: useSelector(requestService, selectIsVerifyingIdentity),
isInvalidIdentity: useSelector(requestService, selectIsInvalidIdentity),

storeError: useSelector(requestService, selectStoreError),

ACCEPT: () => requestService.send(RequestEvents.ACCEPT()),
ACCEPT_AND_VERIFY: () =>
requestService.send(RequestEvents.ACCEPT_AND_VERIFY()),
Expand Down

0 comments on commit 7544c33

Please sign in to comment.