Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Do not manage shareFiles errors in flagship app #1144

Merged
merged 1 commit into from
Jan 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/app/domain/osReceive/models/ShareFiles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import type CozyClient from 'cozy-client'
export interface ShareFilesDependencies {
showOverlay: (message?: string) => void
hideOverlay: () => void
handleError: (message: string) => void
t: (key: string, opts?: Record<string, unknown>) => string
client: CozyClient | null
}
Expand Down
17 changes: 5 additions & 12 deletions src/app/domain/osReceive/services/shareFilesService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import CozyClient, { useClient } from 'cozy-client'
import { FileMetadata } from '/app/domain/osReceive/models/OsReceiveCozyApp'
import { OsReceiveLogger } from '/app/domain/osReceive'
import { useLoadingOverlay } from '/app/view/Loading/LoadingOverlayProvider'
import { useError } from '/app/view/Error/ErrorProvider'
import { useI18n } from '/locales/i18n'
import { getErrorMessage } from '/libs/functions/getErrorMessage'
import {
Expand Down Expand Up @@ -80,8 +79,10 @@ export const fetchFilesByIds = async (

await Share.open({ urls: fileURIs })
} catch (error) {
// Not considered as an error
if (getErrorMessage(error) === 'User did not share') return
// We do not want to log when the user did not share but we want to send it to front end
if (getErrorMessage(error) === 'User did not share') {
throw error
}

OsReceiveLogger.error('fetchFilesByIds: error', error)
throw new Error('Failed to fetch file metadata or download files')
Expand All @@ -92,7 +93,7 @@ const intentShareFiles = async (
dependencies: ShareFilesDependencies,
filesIds: ShareFilesPayload
): Promise<void> => {
const { showOverlay, hideOverlay, handleError, t, client } = dependencies
const { showOverlay, hideOverlay, t, client } = dependencies

try {
if (!filesIds.length) throw new Error('No files to share')
Expand All @@ -101,13 +102,6 @@ const intentShareFiles = async (
showOverlay(t('services.osReceive.shareFiles.downloadingFiles'))

await fetchFilesByIds(client, filesIds)
} catch (error) {
handleError(
t('errors.shareFiles', {
postProcess: 'interval',
count: filesIds.length
})
)
} finally {
hideOverlay()
}
Expand All @@ -117,7 +111,6 @@ export const useShareFiles = (): { shareFiles: ShareFilesIntent } => {
const dependencies = {
showOverlay: useLoadingOverlay().showOverlay,
hideOverlay: useLoadingOverlay().hideOverlay,
handleError: useError().handleError,
t: useI18n().t,
client: useClient()
}
Expand Down
Loading