X-Git-Url: https://git.localhorst.tv/?a=blobdiff_plain;f=resources%2Fjs%2Fcomponents%2Fresults%2FItem.js;h=2e29d752afd2bd6938e82a5123c3b607bdea7308;hb=4c5a82cb876e96c72c50e8bc12bd8a43a9afe847;hp=b8a0ec61ec7f7ca23e42bbdae4b4c14eb5204d96;hpb=1e725fef6dc440aaeea8c30e1e0598dc5d24ad86;p=alttp.git diff --git a/resources/js/components/results/Item.js b/resources/js/components/results/Item.js index b8a0ec6..2e29d75 100644 --- a/resources/js/components/results/Item.js +++ b/resources/js/components/results/Item.js @@ -1,7 +1,7 @@ import PropTypes from 'prop-types'; import React, { useState } from 'react'; import { Button } from 'react-bootstrap'; -import { withTranslation } from 'react-i18next'; +import { useTranslation } from 'react-i18next'; import DetailDialog from './DetailDialog'; import Icon from '../common/Icon'; @@ -9,8 +9,7 @@ import Box from '../users/Box'; import { getIcon, getTime } from '../../helpers/Result'; import { maySeeResults } from '../../helpers/permissions'; import { findResult } from '../../helpers/User'; -import { withUser } from '../../helpers/UserContext'; -import i18n from '../../i18n'; +import { useUser } from '../../hooks/user'; const getClassName = result => { const classNames = ['status']; @@ -51,14 +50,24 @@ const getVoDIcon = result => { }; const Item = ({ - authUser, round, tournament, user, }) => { const [showDialog, setShowDialog] = useState(false); - const result = findResult(user, round); - const maySee = maySeeResults(authUser, tournament, round); + + const { t } = useTranslation(); + const { user: authUser } = useUser(); + + const result = React.useMemo( + () => findResult(user, round), + [round, user], + ); + const maySee = React.useMemo( + () => maySeeResults(authUser, tournament, round), + [authUser, round, tournament], + ); + return
@@ -78,7 +87,7 @@ const Item = ({ href={result.vod} size="sm" target="_blank" - title={i18n.t('results.vod')} + title={t('results.vod')} variant={getVoDVariant(result)} > {getVoDIcon(result)} @@ -96,8 +105,6 @@ const Item = ({ }; Item.propTypes = { - authUser: PropTypes.shape({ - }), round: PropTypes.shape({ }), tournament: PropTypes.shape({ @@ -106,4 +113,4 @@ Item.propTypes = { }), }; -export default withTranslation()(withUser(Item, 'authUser')); +export default Item;