Skip to content

Commit

Permalink
[INJIMOB-854]: Refactor back up and restore Ios changes
Browse files Browse the repository at this point in the history
Signed-off-by: Abhishek Paul <abhishek.paul@thoughtworks.com>
  • Loading branch information
Abhishek Paul authored and abhip2565 committed Apr 10, 2024
1 parent 86ce3bc commit b330859
Show file tree
Hide file tree
Showing 19 changed files with 186 additions and 144 deletions.
22 changes: 12 additions & 10 deletions components/AccountInformation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,23 @@ import {Theme} from './ui/styleUtils';
import {ProfileInfo} from '../shared/CloudBackupAndRestoreUtils';
import {useTranslation} from 'react-i18next';
import testIDProps from '../shared/commonUtil';
import { isAndroid } from '../shared/constants';
import {isAndroid} from '../shared/constants';

export const AccountInformation: React.FC<ProfileInfo> = ({email, picture}) => {
const {t} = useTranslation('AccountSelection');
return (
<Row style={{marginBottom: 21, columnGap: 11}}>
{isAndroid() && <Column align="center">
<Image
{...testIDProps('associatedAccountPicture')}
style={{height: 40, width: 40, borderRadius: 45}}
source={{
uri: picture,
}}
/>
</Column>}
{isAndroid() && (
<Column align="center">
<Image
{...testIDProps('associatedAccountPicture')}
style={{height: 40, width: 40, borderRadius: 45}}
source={{
uri: picture,
}}
/>
</Column>
)}
<Column>
<Row>
<Text
Expand Down
1 change: 0 additions & 1 deletion components/ui/Error.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import testIDProps from '../../shared/commonUtil';
import {Modal} from './Modal';

export const Error: React.FC<ErrorProps> = props => {
console.log("I am error")
const {t} = useTranslation('common');
const errorContent = () => {
return (
Expand Down
2 changes: 1 addition & 1 deletion locales/ara.json
Original file line number Diff line number Diff line change
Expand Up @@ -798,7 +798,7 @@
"lastBackupDetails": "تفاصيل النسخ الاحتياطي الأخير",
"backupInProgress": "لا يزال بإمكانك استخدام التطبيق أثناء إجراء النسخ الاحتياطي للبيانات. سيؤدي إغلاق التطبيق إلى إنهاء عملية النسخ الاحتياطي للبيانات.",
"noBackup": "قم بعمل نسخة احتياطية لبياناتك على {{driveName}}. يمكنك استعادتها عند إعادة تثبيت INJI.",
"storage": "سيتم تخزين النسخة الاحتياطية في Google Drive المرتبط بحساب Gmail الذي اخترته.",
"storage": "سيتم تخزين النسخة الاحتياطية في {{driveName}} المرتبط بحساب {{accountType}} الذي اخترته.",
"backup": "دعم",
"size": "مقاس:",
"restore": "يعيد",
Expand Down
2 changes: 1 addition & 1 deletion locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -806,7 +806,7 @@
"lastBackupDetails": "Last Backup Details",
"backupInProgress": "You can still use the application while data backup is in progress. Closing the app will terminate the data backup process.",
"noBackup": "Backup your Data to {{driveName}}. You can restore them when you reinstall INJI.",
"storage": "The backup will be stored in the Google Drive associated to your chosen gmail account.",
"storage": "The backup will be stored in the {{driveName}} associated to your chosen {{accountType}} account.",
"backup": "Backup",
"size": "Size: ",
"restore": "Restore",
Expand Down
2 changes: 1 addition & 1 deletion locales/fil.json
Original file line number Diff line number Diff line change
Expand Up @@ -797,7 +797,7 @@
"lastBackupDetails": "Mga Detalye ng Huling Backup",
"backupInProgress": "Maaari mo pa ring gamitin ang application habang isinasagawa ang pag-backup ng data. Ang pagsasara ng app ay magwawakas sa proseso ng pag-backup ng data.",
"noBackup": "I-backup ang iyong Data sa {{driveName}}. Maaari mong ibalik ang mga ito kapag na-install mong muli ang INJI.",
"storage": "Ang backup ay maiimbak sa Google Drive na nauugnay sa iyong napiling gmail account.",
"storage": "Ang backup ay maiimbak sa {{driveName}} na nauugnay sa iyong napiling {{accountType}} account.",
"backup": "Backup",
"size": "Size: ",
"restore": "Ibalik",
Expand Down
2 changes: 1 addition & 1 deletion locales/hin.json
Original file line number Diff line number Diff line change
Expand Up @@ -800,7 +800,7 @@
"lastBackupDetails": "अंतिम बैकअप विवरण",
"backupInProgress": "जब डेटा बैकअप चल रहा हो तब भी आप एप्लिकेशन का उपयोग कर सकते हैं। ऐप बंद करने से डेटा बैकअप प्रक्रिया समाप्त हो जाएगी।",
"noBackup": "अपने डेटा का {{driveName}} पर बैकअप लें। INJI को पुनः इंस्टॉल करने पर आप उन्हें पुनर्स्थापित कर सकते हैं।",
"storage": "बैकअप आपके चुने हुए जीमेल खाते से जुड़े Google ड्राइव में संग्रहीत किया जाएगा।",
"storage": "बैकअप आपके चुने हुए {{accountType}} खाते से जुड़े {{driveName}} में संग्रहीत किया जाएगा।",
"backup": "बैकअप",
"size": "आकार: ",
"restore": "पुनर्स्थापित करें",
Expand Down
2 changes: 1 addition & 1 deletion locales/kan.json
Original file line number Diff line number Diff line change
Expand Up @@ -798,7 +798,7 @@
"lastBackupDetails": "ಕೊನೆಯ ಬ್ಯಾಕಪ್ ವಿವರಗಳು",
"backupInProgress": "ಡೇಟಾ ಬ್ಯಾಕಪ್ ಪ್ರಗತಿಯಲ್ಲಿರುವಾಗಲೂ ನೀವು ಅಪ್ಲಿಕೇಶನ್ ಅನ್ನು ಬಳಸಬಹುದು. ಅಪ್ಲಿಕೇಶನ್ ಅನ್ನು ಮುಚ್ಚುವುದರಿಂದ ಡೇಟಾ ಬ್ಯಾಕಪ್ ಪ್ರಕ್ರಿಯೆಯನ್ನು ಕೊನೆಗೊಳಿಸುತ್ತದೆ.",
"noBackup": "{{driveName}} ನಿಮ್ಮ ಡೇಟಾವನ್ನು ಬ್ಯಾಕಪ್ ಮಾಡಿ. ನೀವು INJI ಅನ್ನು ಮರುಸ್ಥಾಪಿಸಿದಾಗ ನೀವು ಅವುಗಳನ್ನು ಮರುಸ್ಥಾಪಿಸಬಹುದು.",
"storage": "ನಿಮ್ಮ ಆಯ್ಕೆಮಾಡಿದ gmail ಖಾತೆಗೆ ಸಂಯೋಜಿತವಾಗಿರುವ Google ಡ್ರೈವ್‌ನಲ್ಲಿ ಬ್ಯಾಕಪ್ ಅನ್ನು ಸಂಗ್ರಹಿಸಲಾಗುತ್ತದೆ.",
"storage": "ನೀವು ಆಯ್ಕೆ ಮಾಡಿದ {{accountType}} ಖಾತೆಗೆ ಸಂಯೋಜಿತವಾಗಿರುವ {{driveName}} ನಲ್ಲಿ ಬ್ಯಾಕಪ್ ಅನ್ನು ಸಂಗ್ರಹಿಸಲಾಗುತ್ತದೆ.",
"backup": "ಬ್ಯಾಕಪ್",
"size": "ಗಾತ್ರ: ",
"restore": "ಮರುಸ್ಥಾಪಿಸು",
Expand Down
2 changes: 1 addition & 1 deletion locales/tam.json
Original file line number Diff line number Diff line change
Expand Up @@ -798,7 +798,7 @@
"lastBackupDetails": "கடைசி காப்பு விவரங்கள்",
"backupInProgress": "தரவு காப்புப்பிரதி செயலில் இருக்கும்போது நீங்கள் பயன்பாட்டைப் பயன்படுத்தலாம். பயன்பாட்டை மூடுவது தரவு காப்புப்பிரதி செயல்முறையை நிறுத்தும்.",
"noBackup": "உங்கள் தரவை {{driveName}} காப்புப் பிரதி எடுக்கவும். நீங்கள் INJI ஐ மீண்டும் நிறுவும் போது அவற்றை மீட்டெடுக்கலாம்.",
"storage": "நீங்கள் தேர்ந்தெடுத்த ஜிமெயில் கணக்குடன் தொடர்புடைய Google இயக்ககத்தில் காப்புப்பிரதி சேமிக்கப்படும்.",
"storage": "நீங்கள் தேர்ந்தெடுத்த {{accountType}} கணக்குடன் தொடர்புடைய {{driveName}} இல் காப்புப்பிரதி சேமிக்கப்படும்.",
"backup": "காப்புப்பிரதி",
"size": "அளவு: ",
"restore": "மீட்டமை",
Expand Down
19 changes: 4 additions & 15 deletions machines/backupAndRestore/backupAndRestoreSetup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,27 +160,18 @@ export const backupAndRestoreSetupMachine = model.createMachine(
{
cond: 'isSignedIn',
actions: ['setProfileInfo', 'unsetIsLoading'],
target: 'backupAndRestore', //backupAndRestore abhishek
target: 'backupAndRestore',
},
{
cond: 'isNetworkError',
actions: 'sendBackupAndRestoreSetupErrorEvent',
target: '.noInternet',
},
{
cond: 'isAuthorised',
cond: 'isAuthorisedAndCloudAccessNotGiven',
actions: ['unsetIsLoading'],
target: '.error',
},
// {
// cond: 'isIOSAndNotSignedIn',
// actions: [
// 'unsetIsLoading',
// 'setErrorReasonAsAccountRequired',
// 'sendBackupAndRestoreSetupErrorEvent',
// ],
// target: 'signIn', // Abhisheks changes (.error)
// },
{
actions: ['unsetIsLoading'],
target: 'signIn',
Expand All @@ -190,7 +181,6 @@ export const backupAndRestoreSetupMachine = model.createMachine(
initial: 'idle',
states: {
idle: {},

error: {
entry: 'unsetIsLoading',
on: {
Expand Down Expand Up @@ -389,9 +379,8 @@ export const backupAndRestoreSetupMachine = model.createMachine(
isSignInSuccessful: (_context, event) => {
return (event.data as SignInResult).status === Cloud.status.SUCCESS;
},
isAuthorised: (_context, event) => {
// console.log((event.data as isSignedInResult).isAuthorisedd)
return (event.data as isSignedInResult).isAuthorisedd || false;
isAuthorisedAndCloudAccessNotGiven: (_context, event) => {
return (event.data as isSignedInResult).isAuthorised || false;
},
},
},
Expand Down
164 changes: 105 additions & 59 deletions machines/backupAndRestore/backupAndRestoreSetup.typegen.ts
Original file line number Diff line number Diff line change
@@ -1,60 +1,106 @@
// This file was automatically generated. Edits will be overwritten

// This file was automatically generated. Edits will be overwritten

export interface Typegen0 {
'@@xstate/typegen': true;
internalEvents: {
"done.invoke.backupAndRestoreSetup.checkSignIn:invocation[0]": { type: "done.invoke.backupAndRestoreSetup.checkSignIn:invocation[0]"; data: unknown; __tip: "See the XState TS docs to learn how to strongly type this." };
"done.invoke.backupAndRestoreSetup.init.checkInternet:invocation[0]": { type: "done.invoke.backupAndRestoreSetup.init.checkInternet:invocation[0]"; data: unknown; __tip: "See the XState TS docs to learn how to strongly type this." };
"done.invoke.signIn:invocation[0]": { type: "done.invoke.signIn:invocation[0]"; data: unknown; __tip: "See the XState TS docs to learn how to strongly type this." };
"error.platform.backupAndRestoreSetup.init.checkInternet:invocation[0]": { type: "error.platform.backupAndRestoreSetup.init.checkInternet:invocation[0]"; data: unknown };
"xstate.init": { type: "xstate.init" };
};
invokeSrcNameMap: {
"checkInternet": "done.invoke.backupAndRestoreSetup.init.checkInternet:invocation[0]";
"isUserSignedAlready": "done.invoke.backupAndRestoreSetup.checkSignIn:invocation[0]";
"signIn": "done.invoke.signIn:invocation[0]";
};
missingImplementations: {
actions: never;
delays: never;
guards: never;
services: never;
};
eventsCausingActions: {
"fetchShowConfirmationInfo": "done.invoke.backupAndRestoreSetup.init.checkInternet:invocation[0]";
"openSettings": "OPEN_SETTINGS";
"sendBackupAndRestoreSetupCancelEvent": "DISMISS" | "GO_BACK";
"sendBackupAndRestoreSetupErrorEvent": "done.invoke.backupAndRestoreSetup.checkSignIn:invocation[0]" | "done.invoke.backupAndRestoreSetup.init.checkInternet:invocation[0]" | "done.invoke.signIn:invocation[0]" | "error.platform.backupAndRestoreSetup.init.checkInternet:invocation[0]";
"sendBackupAndRestoreSetupSuccessEvent": "done.invoke.backupAndRestoreSetup.checkSignIn:invocation[0]" | "done.invoke.signIn:invocation[0]";
"sendDataBackupAndRestoreSetupStartEvent": "HANDLE_BACKUP_AND_RESTORE";
"setAccountSelectionConfirmationShown": "done.invoke.backupAndRestoreSetup.checkSignIn:invocation[0]" | "done.invoke.signIn:invocation[0]";
"setIsLoading": "HANDLE_BACKUP_AND_RESTORE" | "PROCEED" | "TRY_AGAIN";
"setProfileInfo": "done.invoke.backupAndRestoreSetup.checkSignIn:invocation[0]" | "done.invoke.signIn:invocation[0]";
"setShouldTriggerAutoBackup": "done.invoke.signIn:invocation[0]";
"unsetIsLoading": "DISMISS" | "STORE_RESPONSE" | "done.invoke.backupAndRestoreSetup.checkSignIn:invocation[0]" | "done.invoke.backupAndRestoreSetup.init.checkInternet:invocation[0]" | "error.platform.backupAndRestoreSetup.init.checkInternet:invocation[0]";
"unsetShouldTriggerAutoBackup": "HANDLE_BACKUP_AND_RESTORE";
};
eventsCausingDelays: {

};
eventsCausingGuards: {
"isAuthorised": "done.invoke.backupAndRestoreSetup.checkSignIn:invocation[0]";
"isConfirmationAlreadyShown": "STORE_RESPONSE";
"isIOSAndSignInFailed": "done.invoke.signIn:invocation[0]";
"isInternetConnected": "done.invoke.backupAndRestoreSetup.init.checkInternet:invocation[0]";
"isNetworkError": "done.invoke.backupAndRestoreSetup.checkSignIn:invocation[0]" | "done.invoke.signIn:invocation[0]";
"isSignInSuccessful": "done.invoke.signIn:invocation[0]";
"isSignedIn": "done.invoke.backupAndRestoreSetup.checkSignIn:invocation[0]";
};
eventsCausingServices: {
"checkInternet": "HANDLE_BACKUP_AND_RESTORE" | "TRY_AGAIN";
"isUserSignedAlready": "PROCEED" | "STORE_RESPONSE";
"signIn": "done.invoke.backupAndRestoreSetup.checkSignIn:invocation[0]";
};
matchesStates: "backupAndRestore" | "checkSignIn" | "checkSignIn.error" | "checkSignIn.idle" | "checkSignIn.noInternet" | "fetchShowConfirmationInfo" | "init" | "init.checkInternet" | "init.idle" | "init.noInternet" | "selectCloudAccount" | "signIn" | "signIn.error" | "signIn.idle" | "signIn.noInternet" | { "checkSignIn"?: "error" | "idle" | "noInternet";
"init"?: "checkInternet" | "idle" | "noInternet";
"signIn"?: "error" | "idle" | "noInternet"; };
tags: never;
}

export interface Typegen0 {
'@@xstate/typegen': true;
internalEvents: {
'done.invoke.backupAndRestoreSetup.checkSignIn:invocation[0]': {
type: 'done.invoke.backupAndRestoreSetup.checkSignIn:invocation[0]';
data: unknown;
__tip: 'See the XState TS docs to learn how to strongly type this.';
};
'done.invoke.backupAndRestoreSetup.init.checkInternet:invocation[0]': {
type: 'done.invoke.backupAndRestoreSetup.init.checkInternet:invocation[0]';
data: unknown;
__tip: 'See the XState TS docs to learn how to strongly type this.';
};
'done.invoke.signIn:invocation[0]': {
type: 'done.invoke.signIn:invocation[0]';
data: unknown;
__tip: 'See the XState TS docs to learn how to strongly type this.';
};
'error.platform.backupAndRestoreSetup.init.checkInternet:invocation[0]': {
type: 'error.platform.backupAndRestoreSetup.init.checkInternet:invocation[0]';
data: unknown;
};
'xstate.init': {type: 'xstate.init'};
};
invokeSrcNameMap: {
checkInternet: 'done.invoke.backupAndRestoreSetup.init.checkInternet:invocation[0]';
isUserSignedAlready: 'done.invoke.backupAndRestoreSetup.checkSignIn:invocation[0]';
signIn: 'done.invoke.signIn:invocation[0]';
};
missingImplementations: {
actions: never;
delays: never;
guards: never;
services: never;
};
eventsCausingActions: {
fetchShowConfirmationInfo: 'done.invoke.backupAndRestoreSetup.init.checkInternet:invocation[0]';
openSettings: 'OPEN_SETTINGS';
sendBackupAndRestoreSetupCancelEvent: 'DISMISS' | 'GO_BACK';
sendBackupAndRestoreSetupErrorEvent:
| 'done.invoke.backupAndRestoreSetup.checkSignIn:invocation[0]'
| 'done.invoke.backupAndRestoreSetup.init.checkInternet:invocation[0]'
| 'done.invoke.signIn:invocation[0]'
| 'error.platform.backupAndRestoreSetup.init.checkInternet:invocation[0]';
sendBackupAndRestoreSetupSuccessEvent:
| 'done.invoke.backupAndRestoreSetup.checkSignIn:invocation[0]'
| 'done.invoke.signIn:invocation[0]';
sendDataBackupAndRestoreSetupStartEvent: 'HANDLE_BACKUP_AND_RESTORE';
setAccountSelectionConfirmationShown:
| 'done.invoke.backupAndRestoreSetup.checkSignIn:invocation[0]'
| 'done.invoke.signIn:invocation[0]';
setIsLoading: 'HANDLE_BACKUP_AND_RESTORE' | 'PROCEED' | 'TRY_AGAIN';
setProfileInfo:
| 'done.invoke.backupAndRestoreSetup.checkSignIn:invocation[0]'
| 'done.invoke.signIn:invocation[0]';
setShouldTriggerAutoBackup: 'done.invoke.signIn:invocation[0]';
unsetIsLoading:
| 'DISMISS'
| 'STORE_RESPONSE'
| 'done.invoke.backupAndRestoreSetup.checkSignIn:invocation[0]'
| 'done.invoke.backupAndRestoreSetup.init.checkInternet:invocation[0]'
| 'error.platform.backupAndRestoreSetup.init.checkInternet:invocation[0]';
unsetShouldTriggerAutoBackup: 'HANDLE_BACKUP_AND_RESTORE';
};
eventsCausingDelays: {};
eventsCausingGuards: {
isAuthorisedAndCloudAccessNotGiven: 'done.invoke.backupAndRestoreSetup.checkSignIn:invocation[0]';
isConfirmationAlreadyShown: 'STORE_RESPONSE';
isIOSAndSignInFailed: 'done.invoke.signIn:invocation[0]';
isInternetConnected: 'done.invoke.backupAndRestoreSetup.init.checkInternet:invocation[0]';
isNetworkError:
| 'done.invoke.backupAndRestoreSetup.checkSignIn:invocation[0]'
| 'done.invoke.signIn:invocation[0]';
isSignInSuccessful: 'done.invoke.signIn:invocation[0]';
isSignedIn: 'done.invoke.backupAndRestoreSetup.checkSignIn:invocation[0]';
};
eventsCausingServices: {
checkInternet: 'HANDLE_BACKUP_AND_RESTORE' | 'TRY_AGAIN';
isUserSignedAlready: 'PROCEED' | 'STORE_RESPONSE';
signIn: 'done.invoke.backupAndRestoreSetup.checkSignIn:invocation[0]';
};
matchesStates:
| 'backupAndRestore'
| 'checkSignIn'
| 'checkSignIn.error'
| 'checkSignIn.idle'
| 'checkSignIn.noInternet'
| 'fetchShowConfirmationInfo'
| 'init'
| 'init.checkInternet'
| 'init.idle'
| 'init.noInternet'
| 'selectCloudAccount'
| 'signIn'
| 'signIn.error'
| 'signIn.idle'
| 'signIn.noInternet'
| {
checkSignIn?: 'error' | 'idle' | 'noInternet';
init?: 'checkInternet' | 'idle' | 'noInternet';
signIn?: 'error' | 'idle' | 'noInternet';
};
tags: never;
}
8 changes: 0 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
"@iriscan/biometric-sdk-react-native": "0.2.6",
"@mosip/secure-keystore": "^0.1.7",
"@mosip/tuvali": "^0.4.9",
"@pontusab/react-native-apple-authentication": "^1.0.6",
"@react-native-clipboard/clipboard": "^1.10.0",
"@react-native-community/netinfo": "9.3.7",
"@react-native-google-signin/google-signin": "^10.1.1",
Expand Down Expand Up @@ -91,7 +90,6 @@
"react-native-vector-icons": "^10.0.0",
"react-native-zip-archive": "^6.1.0",
"react-test-renderer": "^18.2.0",
"rn-secure-storage": "^3.0.1",
"short-unique-id": "^4.4.4",
"simple-pem2jwk": "^0.2.4",
"telemetry-sdk": "git://github.com/mosip/sunbird-telemetry-sdk.git#f762be5732ee552c0c70bdd540aa4e2701554c71",
Expand Down
Loading

0 comments on commit b330859

Please sign in to comment.