diff --git a/src/photos/components/PhotoBoard.jsx b/src/photos/components/PhotoBoard.jsx index 3404c9f93b..44b4cdafc5 100644 --- a/src/photos/components/PhotoBoard.jsx +++ b/src/photos/components/PhotoBoard.jsx @@ -1,8 +1,8 @@ import styles from '../styles/photoList.styl' -import React, { Component } from 'react' +import React from 'react' import { withContentRect } from 'react-measure' -import { translate } from 'cozy-ui/transpiled/react/I18n' +import { useI18n } from 'cozy-ui/transpiled/react/I18n' import PhotoList from './PhotoList' import { EmptyPhotos } from 'components/Error/Empty' @@ -10,72 +10,69 @@ import Loading from './Loading' import ErrorComponent from 'components/Error/ErrorComponent' import LoadMoreButton from './LoadMoreButton' -export class PhotoBoard extends Component { - render() { - const { - t, - f, - lists, - selected, - photosContext, - showSelection, - onPhotoToggle, - onPhotosSelect, - onPhotosUnselect, - fetchStatus, - hasMore, - fetchMore, - measureRef, - contentRect: { - entry: { width } - }, - lastFetch - } = this.props - const isError = fetchStatus === 'failed' - const isFetching = - (fetchStatus === 'pending' || fetchStatus === 'loading') && !lastFetch +const PhotoBoard = ({ + lists, + selected, + photosContext, + showSelection, + onPhotoToggle, + onPhotosSelect, + onPhotosUnselect, + fetchStatus, + hasMore, + fetchMore, + measureRef, + contentRect: { + entry: { width } + }, + lastFetch +}) => { + const { t, f } = useI18n() - if (isError) { - return - } - if (isFetching) { - return - } - if (!isFetching && (lists.length === 0 || lists[0].photos.length === 0)) { - return - } + const isError = fetchStatus === 'failed' + const isFetching = + (fetchStatus === 'pending' || fetchStatus === 'loading') && !lastFetch - return ( -
- {lists.map((photoList, idx) => ( - - ))} - {hasMore && ( - - )} -
- ) + if (isError) { + return } + if (isFetching) { + return + } + if (!isFetching && (lists.length === 0 || lists[0].photos.length === 0)) { + return + } + + return ( +
+ {lists.map((photoList, idx) => ( + + ))} + {hasMore && ( + + )} +
+ ) } -export default translate()(withContentRect()(PhotoBoard)) +export default withContentRect()(PhotoBoard) diff --git a/src/photos/targets/public/__snapshots__/App.spec.jsx.snap b/src/photos/targets/public/__snapshots__/App.spec.jsx.snap index 0d23e7b7df..713480265e 100644 --- a/src/photos/targets/public/__snapshots__/App.spec.jsx.snap +++ b/src/photos/targets/public/__snapshots__/App.spec.jsx.snap @@ -35,7 +35,7 @@ exports[`Public view should render children when they are present 1`] = ` /> - -