From e99347fcbe9b71f064ecdf98ecaead112e1e00d7 Mon Sep 17 00:00:00 2001 From: Paolo Miguel de Leon Date: Wed, 23 Nov 2022 14:00:49 +0800 Subject: [PATCH] fix(#214): increase sharing timeout --- locales/en.json | 1 + locales/fil.json | 1 + machines/request.ts | 20 ++++---- machines/request.typegen.ts | 6 ++- machines/scan.ts | 20 ++++---- machines/scan.typegen.ts | 8 ++-- screens/Request/RequestScreen.tsx | 64 +++++++++++++------------- screens/Scan/SendVcScreen.strings.json | 1 + screens/Scan/SendVcScreen.tsx | 4 +- 9 files changed, 71 insertions(+), 54 deletions(-) diff --git a/locales/en.json b/locales/en.json index 8bb08e7855..c68c159d7e 100644 --- a/locales/en.json +++ b/locales/en.json @@ -229,6 +229,7 @@ "status": { "sharing": { "title": "Sharing...", + "hint": "Please wait for the receiving device to accept or reject the share.", "timeoutHint": "It's taking longer than expected to share. There could be a problem with the connection." }, "accepted": { diff --git a/locales/fil.json b/locales/fil.json index 69ceab2d28..a59769fad1 100644 --- a/locales/fil.json +++ b/locales/fil.json @@ -229,6 +229,7 @@ "status": { "sharing": { "title": "Pagbabahagi", + "hint": "Pakihintay na tanggapin o tanggihan ng tumatanggap na device ang pagbabahagi.", "timeoutHint": "May katagalan ang pagbabahagi. Maaaring may problema sa koneksyon." }, "accepted": { diff --git a/machines/request.ts b/machines/request.ts index 1ca879c074..85024963ea 100644 --- a/machines/request.ts +++ b/machines/request.ts @@ -211,7 +211,13 @@ export const requestMachine = model.createMachine( }, initial: 'inProgress', states: { - inProgress: {}, + inProgress: { + after: { + SHARING_TIMEOUT: { + target: 'timeout', + }, + }, + }, timeout: { on: { CANCEL: { @@ -221,11 +227,6 @@ export const requestMachine = model.createMachine( }, }, }, - after: { - CONNECTION_TIMEOUT: { - target: '.timeout', - }, - }, }, reviewing: { on: { @@ -680,8 +681,11 @@ export const requestMachine = model.createMachine( delays: { CLEAR_DELAY: 250, - CONNECTION_TIMEOUT: () => { - return (Platform.OS === 'ios' ? 10 : 5) * 1000; + CONNECTION_TIMEOUT: (context) => { + return (context.sharingProtocol === 'ONLINE' ? 15 : 5) * 1000; + }, + SHARING_TIMEOUT: (context) => { + return (context.sharingProtocol === 'ONLINE' ? 45 : 15) * 1000; }, }, } diff --git a/machines/request.typegen.ts b/machines/request.typegen.ts index 82af52ee87..f90e5630d5 100644 --- a/machines/request.typegen.ts +++ b/machines/request.typegen.ts @@ -16,6 +16,9 @@ export interface Typegen0 { 'xstate.after(CLEAR_DELAY)#clearingConnection': { type: 'xstate.after(CLEAR_DELAY)#clearingConnection'; }; + 'xstate.after(SHARING_TIMEOUT)#request.waitingForVc.inProgress': { + type: 'xstate.after(SHARING_TIMEOUT)#request.waitingForVc.inProgress'; + }; 'xstate.init': { type: 'xstate.init' }; 'xstate.stop': { type: 'xstate.stop' }; }; @@ -95,7 +98,8 @@ export interface Typegen0 { }; 'eventsCausingDelays': { CLEAR_DELAY: ''; - CONNECTION_TIMEOUT: 'EXCHANGE_DONE' | 'RECEIVE_DEVICE_INFO'; + CONNECTION_TIMEOUT: 'RECEIVE_DEVICE_INFO'; + SHARING_TIMEOUT: 'EXCHANGE_DONE'; }; 'matchesStates': | 'bluetoothDenied' diff --git a/machines/scan.ts b/machines/scan.ts index 1eebc4e912..cf11af9715 100644 --- a/machines/scan.ts +++ b/machines/scan.ts @@ -295,7 +295,13 @@ export const scanMachine = model.createMachine( }, initial: 'inProgress', states: { - inProgress: {}, + inProgress: { + after: { + SHARING_TIMEOUT: { + target: 'timeout', + }, + }, + }, timeout: { on: { CANCEL: { @@ -305,11 +311,6 @@ export const scanMachine = model.createMachine( }, }, }, - after: { - CONNECTION_TIMEOUT: { - target: '.timeout', - }, - }, }, accepted: { entry: ['logShared'], @@ -685,8 +686,11 @@ export const scanMachine = model.createMachine( delays: { CLEAR_DELAY: 250, - CONNECTION_TIMEOUT: () => { - return (Platform.OS === 'ios' ? 15 : 5) * 1000; + CONNECTION_TIMEOUT: (context) => { + return (context.sharingProtocol === 'ONLINE' ? 15 : 5) * 1000; + }, + SHARING_TIMEOUT: (context) => { + return (context.sharingProtocol === 'ONLINE' ? 45 : 15) * 1000; }, }, } diff --git a/machines/scan.typegen.ts b/machines/scan.typegen.ts index c92ad67c39..e44919dac4 100644 --- a/machines/scan.typegen.ts +++ b/machines/scan.typegen.ts @@ -18,6 +18,9 @@ export interface Typegen0 { 'xstate.after(CLEAR_DELAY)#clearingConnection': { type: 'xstate.after(CLEAR_DELAY)#clearingConnection'; }; + 'xstate.after(SHARING_TIMEOUT)#scan.reviewing.sendingVc.inProgress': { + type: 'xstate.after(SHARING_TIMEOUT)#scan.reviewing.sendingVc.inProgress'; + }; 'xstate.init': { type: 'xstate.init' }; 'xstate.stop': { type: 'xstate.stop' }; }; @@ -114,11 +117,10 @@ export interface Typegen0 { }; 'eventsCausingDelays': { CLEAR_DELAY: 'LOCATION_ENABLED'; - CONNECTION_TIMEOUT: + CONNECTION_TIMEOUT: 'CONNECTED' | 'RECEIVE_DEVICE_INFO'; + SHARING_TIMEOUT: | 'ACCEPT_REQUEST' - | 'CONNECTED' | 'FACE_VALID' - | 'RECEIVE_DEVICE_INFO' | 'done.invoke.scan.reviewing.creatingVp:invocation[0]'; }; 'matchesStates': diff --git a/screens/Request/RequestScreen.tsx b/screens/Request/RequestScreen.tsx index f6865e9fc3..69ac03b557 100644 --- a/screens/Request/RequestScreen.tsx +++ b/screens/Request/RequestScreen.tsx @@ -1,32 +1,30 @@ import React from 'react'; +import { TFunction, useTranslation } from 'react-i18next'; +import { Switch } from 'react-native-elements'; +import { Platform } from 'react-native'; import QRCode from 'react-native-qrcode-svg'; + import { Centered, Button, Row, Column, Text } from '../../components/ui'; import { Theme } from '../../components/ui/styleUtils'; import { useRequestScreen } from './RequestScreenController'; -import { TFunction, useTranslation } from 'react-i18next'; -import { Switch } from 'react-native-elements'; -import { Platform } from 'react-native'; export const RequestScreen: React.FC = () => { const { t } = useTranslation('RequestScreen'); const controller = useRequestScreen(); + const props: RequestScreenProps = { t, controller }; return ( - {controller.isBluetoothDenied && ( - - )} + {controller.isBluetoothDenied && } {!controller.isCheckingBluetoothService && !controller.isBluetoothDenied ? ( - {controller.isWaitingForConnection && ( - - )} - + {controller.isWaitingForConnection && } + ) : null} @@ -48,29 +46,7 @@ const BluetoothPrompt: React.FC = ({ t, controller }) => { ); }; -const StatusMessage: React.FC = ({ t, controller }) => { - return ( - controller.statusMessage !== '' && ( - - {controller.statusMessage} - {controller.statusHint !== '' && ( - - {controller.statusHint} - - )} - {controller.isStatusCancellable && ( -