Skip to content

Commit

Permalink
feat: Avoid to call backup intent when not available
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
zatteo committed Sep 29, 2023
1 parent b8668c3 commit 589896b
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 2 deletions.
16 changes: 16 additions & 0 deletions src/photos/ducks/backup/components/UpdateAppAlert.jsx
Original file line number Diff line number Diff line change
@@ -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 (
<>
<Alert className="u-mt-1">{t('Backup.UpdateAppAlert.description')}</Alert>
</>
)
}

export default UpdateAppAlert
2 changes: 1 addition & 1 deletion src/photos/ducks/backup/hooks/useBackupActions.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ export const BackupActionsProvider = ({ children }) => {
}
}

if (webviewIntent) {
if (webviewIntent && window?.cozy?.flagship?.backup_available) {
check()
}
}, [webviewIntent, checkBackupPermissions, prepareBackup])
Expand Down
13 changes: 12 additions & 1 deletion src/photos/ducks/backup/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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 (
<>
<BackupHeader />
Expand All @@ -30,6 +33,14 @@ const BackupPageContent = () => {
<BackupDescription />
</>
)
} else if (isFlagshipApp() && !isFlagshipAppBackupReady) {
return (
<>
<BackupHeader />
<UpdateAppAlert />
<BackupDescription />
</>
)
} else {
return (
<>
Expand Down
3 changes: 3 additions & 0 deletions src/photos/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -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 - ",
Expand Down

0 comments on commit 589896b

Please sign in to comment.