From 589896b3d1b17a530e27efd2eb1667ade1e9ac38 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o=20Poizat?= Date: Fri, 29 Sep 2023 14:20:53 +0200 Subject: [PATCH] feat: Avoid to call backup intent when not available A window.cozy.backup_available flag was sent by the flagship app but not used. So errors were shown because intent were not available on old flagship app version. --- .../ducks/backup/components/UpdateAppAlert.jsx | 16 ++++++++++++++++ .../ducks/backup/hooks/useBackupActions.jsx | 2 +- src/photos/ducks/backup/index.jsx | 13 ++++++++++++- src/photos/locales/en.json | 3 +++ 4 files changed, 32 insertions(+), 2 deletions(-) create mode 100644 src/photos/ducks/backup/components/UpdateAppAlert.jsx diff --git a/src/photos/ducks/backup/components/UpdateAppAlert.jsx b/src/photos/ducks/backup/components/UpdateAppAlert.jsx new file mode 100644 index 0000000000..05e79922fb --- /dev/null +++ b/src/photos/ducks/backup/components/UpdateAppAlert.jsx @@ -0,0 +1,16 @@ +import React from 'react' + +import { useI18n } from 'cozy-ui/transpiled/react/I18n' +import Alert from 'cozy-ui/transpiled/react/Alert' + +const UpdateAppAlert = () => { + const { t } = useI18n() + + return ( + <> + {t('Backup.UpdateAppAlert.description')} + + ) +} + +export default UpdateAppAlert diff --git a/src/photos/ducks/backup/hooks/useBackupActions.jsx b/src/photos/ducks/backup/hooks/useBackupActions.jsx index 290c0c1601..0c41bb2df1 100644 --- a/src/photos/ducks/backup/hooks/useBackupActions.jsx +++ b/src/photos/ducks/backup/hooks/useBackupActions.jsx @@ -111,7 +111,7 @@ export const BackupActionsProvider = ({ children }) => { } } - if (webviewIntent) { + if (webviewIntent && window?.cozy?.flagship?.backup_available) { check() } }, [webviewIntent, checkBackupPermissions, prepareBackup]) diff --git a/src/photos/ducks/backup/index.jsx b/src/photos/ducks/backup/index.jsx index 5eae64b43a..c7230849d8 100644 --- a/src/photos/ducks/backup/index.jsx +++ b/src/photos/ducks/backup/index.jsx @@ -10,6 +10,7 @@ import BackupInfo from './components/BackupInfo' import BackupActions from './components/BackupActions' import BackupDescription from './components/BackupDescription' import InstallAppAlert from './components/InstallAppAlert' +import UpdateAppAlert from './components/UpdateAppAlert' import LastBackupStatus from './components/LastBackupStatus' import AllowPermissionsModal from './components/AllowPermissionsModal' import { BackupError } from './components/BackupError' @@ -20,7 +21,9 @@ import { isFlagshipApp } from 'cozy-device-helper' const BackupPageContent = () => { const { isMobile } = useBreakpoints() - if (isFlagshipApp()) { + const isFlagshipAppBackupReady = window?.cozy?.flagship?.backup_available + + if (isFlagshipApp() && isFlagshipAppBackupReady) { return ( <> @@ -30,6 +33,14 @@ const BackupPageContent = () => { ) + } else if (isFlagshipApp() && !isFlagshipAppBackupReady) { + return ( + <> + + + + + ) } else { return ( <> diff --git a/src/photos/locales/en.json b/src/photos/locales/en.json index 186913cd9f..db13ea5634 100755 --- a/src/photos/locales/en.json +++ b/src/photos/locales/en.json @@ -308,6 +308,9 @@ "description": "Backup automatically all your photos and videos from your mobile devices", "install": "Install our app" }, + "UpdateAppAlert": { + "description": "Update your app to backup automatically all your photos and videos" + }, "LastBackupStatus": { "lastBackup": "Last backup: ", "success": "Success - ",