From 19178807f8cc341cc14f087c1daad487534dd2d9 Mon Sep 17 00:00:00 2001 From: sylenien Date: Fri, 13 May 2022 13:35:27 +0200 Subject: [PATCH] fix(ui): fixed sessionitem types and removed withrouter connection --- .../components/shared/SessionItem/SessionItem.tsx | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/frontend/app/components/shared/SessionItem/SessionItem.tsx b/frontend/app/components/shared/SessionItem/SessionItem.tsx index f00f58c82..d8e485fbb 100644 --- a/frontend/app/components/shared/SessionItem/SessionItem.tsx +++ b/frontend/app/components/shared/SessionItem/SessionItem.tsx @@ -11,7 +11,7 @@ import { observer } from 'mobx-react-lite'; import { durationFormatted, formatTimeOrDate } from 'App/date'; import stl from './sessionItem.css'; import Counter from './Counter' -import { withRouter, RouteComponentProps } from 'react-router-dom'; +import { useLocation, RouteComponentProps } from 'react-router-dom'; import SessionMetaList from './SessionMetaList'; import PlayLink from './PlayLink'; import ErrorBars from './ErrorBars'; @@ -55,7 +55,7 @@ interface Props { }, } -function SessionItem(props: RouteComponentProps) { +function SessionItem(props: Props) { const { settingsStore } = useStore(); const { timezone } = settingsStore.sessionSettings; @@ -87,10 +87,14 @@ function SessionItem(props: RouteComponentProps) { lastPlayedSessionId, } = props; + const location = useLocation(); + + console.log(location.pathname); + const formattedDuration = durationFormatted(duration); const hasUserId = userId || userAnonymousId; - const isSessions = isRoute(SESSIONS_ROUTE, props.location.pathname); - const isAssist = isRoute(ASSIST_ROUTE, props.location.pathname) || isRoute(ASSIST_LIVE_SESSION, props.location.pathname); + const isSessions = isRoute(SESSIONS_ROUTE, location.pathname); + const isAssist = isRoute(ASSIST_ROUTE, location.pathname) || isRoute(ASSIST_LIVE_SESSION, location.pathname); const isLastPlayed = lastPlayedSessionId === sessionId; const _metaList = Object.keys(metadata).filter(i => metaList.includes(i)).map(key => { @@ -182,4 +186,4 @@ function SessionItem(props: RouteComponentProps) { ) } -export default withRouter(observer(SessionItem)) +export default observer(SessionItem)