From b3308593eced16d53fd859a76940c8760a422b00 Mon Sep 17 00:00:00 2001 From: Abhishek Paul Date: Wed, 10 Apr 2024 14:26:06 +0530 Subject: [PATCH] [INJIMOB-854]: Refactor back up and restore Ios changes Signed-off-by: Abhishek Paul --- components/AccountInformation.tsx | 22 +-- components/ui/Error.tsx | 1 - locales/ara.json | 2 +- locales/en.json | 2 +- locales/fil.json | 2 +- locales/hin.json | 2 +- locales/kan.json | 2 +- locales/tam.json | 2 +- .../backupAndRestore/backupAndRestoreSetup.ts | 19 +- .../backupAndRestoreSetup.typegen.ts | 164 +++++++++++------- package-lock.json | 8 - package.json | 2 - screens/HomeScreenLayout.tsx | 4 +- screens/Settings/DataBackupAndRestore.tsx | 21 +-- .../BackupAndRestoreScreen.tsx | 27 ++- .../BackupAndRestoreSetupController.ts | 7 +- shared/CloudBackupAndRestoreUtils.ts | 31 ++-- shared/commonUtil.ts | 10 +- shared/constants.ts | 2 + 19 files changed, 186 insertions(+), 144 deletions(-) diff --git a/components/AccountInformation.tsx b/components/AccountInformation.tsx index 67681f7a02..1392a6acd5 100644 --- a/components/AccountInformation.tsx +++ b/components/AccountInformation.tsx @@ -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 = ({email, picture}) => { const {t} = useTranslation('AccountSelection'); return ( - {isAndroid() && - - } + {isAndroid() && ( + + + + )} = props => { - console.log("I am error") const {t} = useTranslation('common'); const errorContent = () => { return ( diff --git a/locales/ara.json b/locales/ara.json index 53f330b18e..844e849935 100644 --- a/locales/ara.json +++ b/locales/ara.json @@ -798,7 +798,7 @@ "lastBackupDetails": "تفاصيل النسخ الاحتياطي الأخير", "backupInProgress": "لا يزال بإمكانك استخدام التطبيق أثناء إجراء النسخ الاحتياطي للبيانات. سيؤدي إغلاق التطبيق إلى إنهاء عملية النسخ الاحتياطي للبيانات.", "noBackup": "قم بعمل نسخة احتياطية لبياناتك على {{driveName}}. يمكنك استعادتها عند إعادة تثبيت INJI.", - "storage": "سيتم تخزين النسخة الاحتياطية في Google Drive المرتبط بحساب Gmail الذي اخترته.", + "storage": "سيتم تخزين النسخة الاحتياطية في {{driveName}} المرتبط بحساب {{accountType}} الذي اخترته.", "backup": "دعم", "size": "مقاس:", "restore": "يعيد", diff --git a/locales/en.json b/locales/en.json index ff7fde1a67..e15e8ea518 100644 --- a/locales/en.json +++ b/locales/en.json @@ -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", diff --git a/locales/fil.json b/locales/fil.json index a989a1c0b7..ebe6c5f7ed 100644 --- a/locales/fil.json +++ b/locales/fil.json @@ -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", diff --git a/locales/hin.json b/locales/hin.json index 5bc8909ed7..5c310ae739 100644 --- a/locales/hin.json +++ b/locales/hin.json @@ -800,7 +800,7 @@ "lastBackupDetails": "अंतिम बैकअप विवरण", "backupInProgress": "जब डेटा बैकअप चल रहा हो तब भी आप एप्लिकेशन का उपयोग कर सकते हैं। ऐप बंद करने से डेटा बैकअप प्रक्रिया समाप्त हो जाएगी।", "noBackup": "अपने डेटा का {{driveName}} पर बैकअप लें। INJI को पुनः इंस्टॉल करने पर आप उन्हें पुनर्स्थापित कर सकते हैं।", - "storage": "बैकअप आपके चुने हुए जीमेल खाते से जुड़े Google ड्राइव में संग्रहीत किया जाएगा।", + "storage": "बैकअप आपके चुने हुए {{accountType}} खाते से जुड़े {{driveName}} में संग्रहीत किया जाएगा।", "backup": "बैकअप", "size": "आकार: ", "restore": "पुनर्स्थापित करें", diff --git a/locales/kan.json b/locales/kan.json index a6fe8e2f8a..c54e0860a6 100644 --- a/locales/kan.json +++ b/locales/kan.json @@ -798,7 +798,7 @@ "lastBackupDetails": "ಕೊನೆಯ ಬ್ಯಾಕಪ್ ವಿವರಗಳು", "backupInProgress": "ಡೇಟಾ ಬ್ಯಾಕಪ್ ಪ್ರಗತಿಯಲ್ಲಿರುವಾಗಲೂ ನೀವು ಅಪ್ಲಿಕೇಶನ್ ಅನ್ನು ಬಳಸಬಹುದು. ಅಪ್ಲಿಕೇಶನ್ ಅನ್ನು ಮುಚ್ಚುವುದರಿಂದ ಡೇಟಾ ಬ್ಯಾಕಪ್ ಪ್ರಕ್ರಿಯೆಯನ್ನು ಕೊನೆಗೊಳಿಸುತ್ತದೆ.", "noBackup": "{{driveName}} ನಿಮ್ಮ ಡೇಟಾವನ್ನು ಬ್ಯಾಕಪ್ ಮಾಡಿ. ನೀವು INJI ಅನ್ನು ಮರುಸ್ಥಾಪಿಸಿದಾಗ ನೀವು ಅವುಗಳನ್ನು ಮರುಸ್ಥಾಪಿಸಬಹುದು.", - "storage": "ನಿಮ್ಮ ಆಯ್ಕೆಮಾಡಿದ gmail ಖಾತೆಗೆ ಸಂಯೋಜಿತವಾಗಿರುವ Google ಡ್ರೈವ್‌ನಲ್ಲಿ ಬ್ಯಾಕಪ್ ಅನ್ನು ಸಂಗ್ರಹಿಸಲಾಗುತ್ತದೆ.", + "storage": "ನೀವು ಆಯ್ಕೆ ಮಾಡಿದ {{accountType}} ಖಾತೆಗೆ ಸಂಯೋಜಿತವಾಗಿರುವ {{driveName}} ನಲ್ಲಿ ಬ್ಯಾಕಪ್ ಅನ್ನು ಸಂಗ್ರಹಿಸಲಾಗುತ್ತದೆ.", "backup": "ಬ್ಯಾಕಪ್", "size": "ಗಾತ್ರ: ", "restore": "ಮರುಸ್ಥಾಪಿಸು", diff --git a/locales/tam.json b/locales/tam.json index cd6166581d..883540f557 100644 --- a/locales/tam.json +++ b/locales/tam.json @@ -798,7 +798,7 @@ "lastBackupDetails": "கடைசி காப்பு விவரங்கள்", "backupInProgress": "தரவு காப்புப்பிரதி செயலில் இருக்கும்போது நீங்கள் பயன்பாட்டைப் பயன்படுத்தலாம். பயன்பாட்டை மூடுவது தரவு காப்புப்பிரதி செயல்முறையை நிறுத்தும்.", "noBackup": "உங்கள் தரவை {{driveName}} காப்புப் பிரதி எடுக்கவும். நீங்கள் INJI ஐ மீண்டும் நிறுவும் போது அவற்றை மீட்டெடுக்கலாம்.", - "storage": "நீங்கள் தேர்ந்தெடுத்த ஜிமெயில் கணக்குடன் தொடர்புடைய Google இயக்ககத்தில் காப்புப்பிரதி சேமிக்கப்படும்.", + "storage": "நீங்கள் தேர்ந்தெடுத்த {{accountType}} கணக்குடன் தொடர்புடைய {{driveName}} இல் காப்புப்பிரதி சேமிக்கப்படும்.", "backup": "காப்புப்பிரதி", "size": "அளவு: ", "restore": "மீட்டமை", diff --git a/machines/backupAndRestore/backupAndRestoreSetup.ts b/machines/backupAndRestore/backupAndRestoreSetup.ts index 5ee204e140..717fa51936 100644 --- a/machines/backupAndRestore/backupAndRestoreSetup.ts +++ b/machines/backupAndRestore/backupAndRestoreSetup.ts @@ -160,7 +160,7 @@ export const backupAndRestoreSetupMachine = model.createMachine( { cond: 'isSignedIn', actions: ['setProfileInfo', 'unsetIsLoading'], - target: 'backupAndRestore', //backupAndRestore abhishek + target: 'backupAndRestore', }, { cond: 'isNetworkError', @@ -168,19 +168,10 @@ export const backupAndRestoreSetupMachine = model.createMachine( 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', @@ -190,7 +181,6 @@ export const backupAndRestoreSetupMachine = model.createMachine( initial: 'idle', states: { idle: {}, - error: { entry: 'unsetIsLoading', on: { @@ -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; }, }, }, diff --git a/machines/backupAndRestore/backupAndRestoreSetup.typegen.ts b/machines/backupAndRestore/backupAndRestoreSetup.typegen.ts index f422ebd36a..949d80c588 100644 --- a/machines/backupAndRestore/backupAndRestoreSetup.typegen.ts +++ b/machines/backupAndRestore/backupAndRestoreSetup.typegen.ts @@ -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; - } - \ No newline at end of file +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; +} diff --git a/package-lock.json b/package-lock.json index 5d0533bf84..8597c8447d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -33688,14 +33688,6 @@ } } }, - "@pontusab/react-native-apple-authentication": { - "version": "1.0.6", - "resolved": "https://registry.npmjs.org/@pontusab/react-native-apple-authentication/-/react-native-apple-authentication-1.0.6.tgz", - "integrity": "sha512-/Jzpbj3CBoyDoH3LdsJn68S5Q7NZzPYJuAxMfHdMg3D7ruDjTvZELfbGDD1QbcUh6KnZwOfHExar7Vchu5/ehw==", - "requires": { - "react": "18.2.0" - } - }, "@react-native-clipboard/clipboard": { "version": "1.11.2", "resolved": "https://registry.npmjs.org/@react-native-clipboard/clipboard/-/clipboard-1.11.2.tgz", diff --git a/package.json b/package.json index eeb4585cc0..30bbcaf95a 100644 --- a/package.json +++ b/package.json @@ -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", @@ -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", diff --git a/screens/HomeScreenLayout.tsx b/screens/HomeScreenLayout.tsx index c86add0671..d0446e58e2 100644 --- a/screens/HomeScreenLayout.tsx +++ b/screens/HomeScreenLayout.tsx @@ -48,12 +48,12 @@ export const HomeScreenLayout: React.FC = props => { + {SvgImage.infoIcon()} - + {t('help')} diff --git a/screens/Settings/DataBackupAndRestore.tsx b/screens/Settings/DataBackupAndRestore.tsx index 6a2269fe70..9456be02ba 100644 --- a/screens/Settings/DataBackupAndRestore.tsx +++ b/screens/Settings/DataBackupAndRestore.tsx @@ -34,7 +34,6 @@ export const DataBackupAndRestore: React.FC = ({} = () => { controller.isSigningIn, delay, ); - console.warn(controller.isCloudSignInFailed) return ( { - {(controller.isSigningInFailed && !isIOS() || (controller.isCloudSignInFailed && isIOS())) && ( + {((controller.isSigningInFailed && !isIOS()) || + (controller.isCloudSignInFailed && isIOS())) && ( { /> )} - {((isSigningIn || isSigningInSuccessful) && !controller.isCloudSignInFailed) && ( - - )} + {(isSigningIn || isSigningInSuccessful) && + !controller.isCloudSignInFailed && ( + + )} {isLoaderVisible && } = props => { const restoreController = useBackupRestoreScreen(); const {t} = useTranslation('BackupAndRestore'); - + useEffect(() => { if (!props.isSigningIn) { backupController.LAST_BACKUP_DETAILS(); @@ -142,7 +145,10 @@ const BackupAndRestoreScreen: React.FC = props => { - {t('storage')} + {t('storage', { + driveName: getDriveName(), + accountType: getAccountType(), + })} = props => { - {t( - 'The backup will be stored in the iCloud associated to your chosen Apple account', - )} + {t('storage', { + driveName: getDriveName(), + accountType: getAccountType(), + })} = props => { arrowLeft={true} headerRight={ + {SvgImage.infoIcon()} - + {t('Help?')} diff --git a/screens/backupAndRestore/BackupAndRestoreSetupController.ts b/screens/backupAndRestore/BackupAndRestoreSetupController.ts index f24ed275a0..876596b8ea 100644 --- a/screens/backupAndRestore/BackupAndRestoreSetupController.ts +++ b/screens/backupAndRestore/BackupAndRestoreSetupController.ts @@ -72,7 +72,10 @@ export function useBackupAndRestoreSetup() { backupAndRestoreSetupService, selectIsSigningInFailure, ), - isCloudSignInFailed:useSelector(backupAndRestoreSetupService,selectIsCloudSignedInFailed), + isCloudSignInFailed: useSelector( + backupAndRestoreSetupService, + selectIsCloudSignedInFailed, + ), isSigningInSuccessful: useSelector( backupAndRestoreSetupService, selectIsSigningInSuccessful, @@ -114,5 +117,3 @@ export function useBackupAndRestoreSetup() { }, }; } - - diff --git a/shared/CloudBackupAndRestoreUtils.ts b/shared/CloudBackupAndRestoreUtils.ts index 6151cd4e8e..f33fa31690 100644 --- a/shared/CloudBackupAndRestoreUtils.ts +++ b/shared/CloudBackupAndRestoreUtils.ts @@ -134,7 +134,7 @@ class Cloud { static async signIn(): Promise { if (isIOS()) { - let profile; + let profileInfo; // start a login request try { @@ -142,19 +142,16 @@ class Cloud { requestedOperation: appleAuth.Operation.LOGIN, requestedScopes: [appleAuth.Scope.FULL_NAME, appleAuth.Scope.EMAIL], }); - // const decodedToken=jwt_decode(appleAuthRequestResponse.identityToken + "") - // console.log('appleAuthRequestResponse', appleAuthRequestResponse); - // console.log(decodedToken); const {email, nonce, identityToken, realUserStatus /* etc */} = appleAuthRequestResponse; - profile = {email: email, picture: null}; + profileInfo = {email: email, picture: null}; await RNSecureStorage.set( 'userIdentifier', JSON.stringify(appleAuthRequestResponse), {accessible: ACCESSIBLE.WHEN_UNLOCKED}, ); - return {status: this.status.SUCCESS, profileInfo: profile}; + return {status: this.status.SUCCESS, profileInfo: profileInfo}; } catch (error) { if (error.code === appleAuth.Error.CANCELED) { console.warn('User canceled Apple Sign in.'); @@ -170,8 +167,6 @@ class Cloud { }; } } - - // Extract the user's email address from the response } this.configure(); try { @@ -218,21 +213,21 @@ class Cloud { const email = userToken.email; const credentialState = await appleAuth.getCredentialStateForUser(user); - let profile = {email: email, picture: undefined}; + const profileInfo = {email: email, picture: undefined}; if ( credentialState === appleAuth.State.AUTHORIZED && - isSignedIn == true + isSignedIn === true ) { return { isSignedIn: true, - isAuthorisedd: true, - profileInfo: profile, + isAuthorised: true, + profileInfo: profileInfo, }; } else { return { isSignedIn: false, - isAuthorisedd: true, - profileInfo: profile, + isAuthorised: true, + profileInfo: profileInfo, }; } } @@ -244,14 +239,14 @@ class Cloud { return { isSignedIn: true, profileInfo, - isAuthorisedd: true, + isAuthorised: true, }; } else { const profileInfo = await this.profileInfo(); return { isSignedIn: true, profileInfo, - isAuthorisedd: true, + isAuthorised: true, }; } } catch (error) { @@ -265,7 +260,7 @@ class Cloud { return { error: errorReason || error, isSignedIn: false, - isAuthorisedd: false, + isAuthorised: false, }; } } @@ -498,7 +493,7 @@ export type isSignedInResult = { isSignedIn: boolean; error?: string | null; profileInfo?: ProfileInfo; - isAuthorisedd?: boolean; + isAuthorised?: boolean; }; export type CloudUploadResult = { diff --git a/shared/commonUtil.ts b/shared/commonUtil.ts index 447ff5037b..07e759dba4 100644 --- a/shared/commonUtil.ts +++ b/shared/commonUtil.ts @@ -1,7 +1,13 @@ import argon2 from 'react-native-argon2'; import {AnyState} from 'xstate'; import {getDeviceNameSync} from 'react-native-device-info'; -import {GOOGLE_DRIVE_NAME, ICLOUD_DRIVE_NAME, isAndroid} from './constants'; +import { + GOOGLE_DRIVE_NAME, + ICLOUD_DRIVE_NAME, + isAndroid, + GMAIL, + APPLE, +} from './constants'; import {generateSecureRandom} from 'react-native-securerandom'; import forge from 'node-forge'; import {useEffect, useState} from 'react'; @@ -113,6 +119,8 @@ export const bytesToMB = (bytes: number): string => { return Number(megabytes).toFixed(2); }; +export const getAccountType = () => (isAndroid() ? GMAIL : APPLE); + export const getDriveName = () => isAndroid() ? GOOGLE_DRIVE_NAME : ICLOUD_DRIVE_NAME; diff --git a/shared/constants.ts b/shared/constants.ts index 6b62722073..3f498fbe2b 100644 --- a/shared/constants.ts +++ b/shared/constants.ts @@ -125,4 +125,6 @@ export const IOS_SIGNIN_FAILED = 'iCloud not available'; export const REQUEST_TIMEOUT = 'request timedout'; export const BIOMETRIC_CANCELLED = 'User has cancelled biometric'; export const GOOGLE_DRIVE_NAME = 'Google Drive'; +export const GMAIL = 'gmail'; +export const APPLE = 'Apple'; export const ICLOUD_DRIVE_NAME = 'iCloud';