diff --git a/locales/en.json b/locales/en.json index 9345839b8e..9199927417 100644 --- a/locales/en.json +++ b/locales/en.json @@ -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." } } }, diff --git a/machines/openIdBle/request.ts b/machines/openIdBle/request.ts index 0e8b3ada1b..701daecc8b 100644 --- a/machines/openIdBle/request.ts +++ b/machines/openIdBle/request.ts @@ -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' @@ -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 }), @@ -385,6 +386,7 @@ export const requestMachine = }, on: { STORE_ERROR: { + actions: 'setStoringError', target: '#request.reviewing.savingFailed', }, }, @@ -537,6 +539,10 @@ export const requestMachine = }, }), + setStoringError: assign({ + storeError: (_context, event) => event.error, + }), + registerLoggers: assign({ loggers: () => { if (__DEV__) { @@ -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'); } diff --git a/machines/openIdBle/request.typegen.ts b/machines/openIdBle/request.typegen.ts index 575bab80ff..22954da07a 100644 --- a/machines/openIdBle/request.typegen.ts +++ b/machines/openIdBle/request.typegen.ts @@ -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'; }; diff --git a/screens/Request/ReceiveVcScreen.strings.json b/screens/Request/ReceiveVcScreen.strings.json index e7d7573244..143f620165 100644 --- a/screens/Request/ReceiveVcScreen.strings.json +++ b/screens/Request/ReceiveVcScreen.strings.json @@ -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." } } } diff --git a/screens/Request/ReceiveVcScreen.tsx b/screens/Request/ReceiveVcScreen.tsx index 3a0fe26591..6aa55328f8 100644 --- a/screens/Request/ReceiveVcScreen.tsx +++ b/screens/Request/ReceiveVcScreen.tsx @@ -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 ( @@ -117,11 +124,13 @@ export const ReceiveVcScreen: React.FC = () => { diff --git a/screens/Request/ReceiveVcScreenController.ts b/screens/Request/ReceiveVcScreenController.ts index 0a0022248a..c587f63f04 100644 --- a/screens/Request/ReceiveVcScreenController.ts +++ b/screens/Request/ReceiveVcScreenController.ts @@ -14,6 +14,7 @@ import { GlobalContext } from '../../shared/GlobalContext'; import { selectIsAccepting, selectIsSavingFailedIdle, + selectStoreError, } from '../../machines/openIdBle/request'; export function useReceiveVcScreen() { @@ -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()),