From 98f3f0bf33141d0d4f376a061ea5e3f8fce3a5ea Mon Sep 17 00:00:00 2001 From: Ldoppea Date: Thu, 12 Sep 2024 18:12:16 +0200 Subject: [PATCH] feat(cozy-viewer): Use new `downloadFile()` method from cozy-client In cozy/cozy-client#1518 we implemented a new `downloadFile()` that allow to download files as before in a browser, but will download files through cozy-intent when hosted in the Flagship app This commit will replace the old way to download files with the new one using `downloadFile()` BREAKING CHANGE: `downloadFile()` method has been removed from `cozy-viewer/src/helpers.js`. Use the one from `cozy-client/dist/models/file` instead --- .../src/NoViewer/DownloadButton.jsx | 7 +++--- .../src/ViewersByFile/PdfMobileViewer.jsx | 7 ++++-- .../cozy-viewer/src/components/Toolbar.jsx | 6 +++-- packages/cozy-viewer/src/helpers.js | 7 ------ packages/cozy-viewer/src/helpers.spec.js | 25 ------------------- 5 files changed, 13 insertions(+), 39 deletions(-) diff --git a/packages/cozy-viewer/src/NoViewer/DownloadButton.jsx b/packages/cozy-viewer/src/NoViewer/DownloadButton.jsx index 5458c82df1..a5f1d06f88 100644 --- a/packages/cozy-viewer/src/NoViewer/DownloadButton.jsx +++ b/packages/cozy-viewer/src/NoViewer/DownloadButton.jsx @@ -2,18 +2,19 @@ import PropTypes from 'prop-types' import React from 'react' import { withClient } from 'cozy-client' +import { downloadFile } from 'cozy-client/dist/models/file' +import { useWebviewIntent } from 'cozy-intent' import Button from 'cozy-ui/transpiled/react/deprecated/Button' import { FileDoctype } from 'cozy-ui/transpiled/react/proptypes' import { useI18n } from 'cozy-ui/transpiled/react/providers/I18n' -import { downloadFile } from '../helpers' - const DownloadButton = ({ client, file, url }) => { const { t } = useI18n() + const webviewIntent = useWebviewIntent() return (