From 335d7667b5a3ac34c1bf5318042c83924924cb5a Mon Sep 17 00:00:00 2001 From: Nuwan Date: Thu, 30 Nov 2023 09:59:11 +0530 Subject: [PATCH] fix latency badge and avatar image --- .../src/components/profile/JKLatencyBadge.js | 4 +- .../components/profile/JKProfileSidePanel.js | 78 ++++++++++--------- .../src/components/sessions/JKSessionUser.js | 19 ++++- 3 files changed, 58 insertions(+), 43 deletions(-) diff --git a/jam-ui/src/components/profile/JKLatencyBadge.js b/jam-ui/src/components/profile/JKLatencyBadge.js index 9dc004150..2d31034ad 100644 --- a/jam-ui/src/components/profile/JKLatencyBadge.js +++ b/jam-ui/src/components/profile/JKLatencyBadge.js @@ -49,10 +49,10 @@ const JKLatencyBadge = ({ latencyData, showAll, showBadgeOnly }) => { return showBadgeOnly ? ( {label} ) : ( -
+ <> {latencyInfo} {label} -
+ ); }; diff --git a/jam-ui/src/components/profile/JKProfileSidePanel.js b/jam-ui/src/components/profile/JKProfileSidePanel.js index 9e57ae65c..11686c311 100644 --- a/jam-ui/src/components/profile/JKProfileSidePanel.js +++ b/jam-ui/src/components/profile/JKProfileSidePanel.js @@ -8,7 +8,7 @@ import { Modal, ModalBody, ModalHeader } from 'reactstrap'; import ScrollBarCustom from '../common/ScrollBarCustom'; import { useAuth } from '../../context/UserAuth'; -import { useTranslation } from "react-i18next"; +import { useTranslation } from 'react-i18next'; import JKProfileAvatar from './JKProfileAvatar'; import JKProfileInstrumentsList from './JKProfileInstrumentsList'; @@ -23,31 +23,29 @@ import JKLatencyBadge from './JKLatencyBadge'; import JKLastActiveAgo from './JKLastActiveAgo'; import JKProfileSkillLevel from './JKProfileSkillLevel'; - const JKProfileSidePanel = props => { const { show, setShow, user, latencyData } = props; const { currentUser } = useAuth(); const toggle = () => setShow(!show); - const {t} = useTranslation(); - + const { t } = useTranslation(); + const joinedDate = () => { - try{ + try { return moment(new Date(parseInt(user.created_at_timestamp) * 1000)).format('MM-DD-YYYY'); - }catch(e){ + } catch (e) { return 'Not specified'; } - }; const location = () => { - if(user.location && user.location.trim().length && user.country && user.country.trim().length){ + if (user.location && user.location.trim().length && user.country && user.country.trim().length) { return `${user.location}, ${user.country}`; - }else if(user.country && user.country.trim().length){ - return user.country; - }else{ - return "Not specified"; + } else if (user.country && user.country.trim().length) { + return user.country; + } else { + return 'Not specified'; } - } + }; return ( { {user && (
- +

{user.name}

@@ -79,28 +77,31 @@ const JKProfileSidePanel = props => { {user && (
-

- {t('person_attributes.latency_to_me', {ns: 'people'})}: +

+ {t('person_attributes.latency_to_me', { ns: 'people' })}:{' '} +
- {t('person_attributes.location', {ns: 'people'})}: {`${location()}`} + {t('person_attributes.location', { ns: 'people' })}: {`${location()}`}
- {t('person_attributes.skill_level', {ns: 'people'})}: + {t('person_attributes.skill_level', { ns: 'people' })}:{' '} +
- {t('person_attributes.joined_jamkazam', {ns: 'people'})}: {joinedDate()} + {t('person_attributes.joined_jamkazam', { ns: 'people' })}: {joinedDate()}
- {t('person_attributes.last_active', {ns: 'people'})}: -

+ {t('person_attributes.last_active', { ns: 'people' })}:{' '} + +
{user.biography && user.biography.length > 0 && (
-
{t('person_attributes.about', {ns: 'people'})}
+
{t('person_attributes.about', { ns: 'people' })}

{user.biography}

)} {user.instruments && user.instruments.length && (
-
{t('person_attributes.instruments', {ns: 'people'})}
+
{t('person_attributes.instruments', { ns: 'people' })}
)} @@ -108,28 +109,28 @@ const JKProfileSidePanel = props => { {user.genres && user.genres.length > 0 && (

-
{t('person_attributes.genres', {ns: 'people'})}
+
{t('person_attributes.genres', { ns: 'people' })}
)} - + {user.bands && user.bands.length > 0 && (

-
{t('person_attributes.bands', {ns: 'people'})}
+
{t('person_attributes.bands', { ns: 'people' })}
{user.bands.map(band => ( -

- +

+ {band.name}

))}
)} - + {user.performance_samples && user.performance_samples.length > 0 && (
-
{t('person_attributes.performance_samples', {ns: 'people'})}
+
{t('person_attributes.performance_samples', { ns: 'people' })}
)} @@ -137,17 +138,17 @@ const JKProfileSidePanel = props => { {user.online_presences && user.online_presences.length > 0 && (

-
{t('person_attributes.online_presence', {ns: 'people'})}
+
{t('person_attributes.online_presence', { ns: 'people' })}
)}
- + {user.genres && user.genres.length > 0 && ( <> -
{t('person_attributes.interests', {ns: 'people'})}
- +
{t('person_attributes.interests', { ns: 'people' })}
+ )} @@ -158,17 +159,20 @@ const JKProfileSidePanel = props => { user={user} addContent={ <> - {t('add_friend', {ns: 'people'})}{' '} + {' '} + {t('add_friend', { ns: 'people' })}{' '} } removeContent={ <> - {t('disconnect', {ns: 'people'})} + {' '} + {t('disconnect', { ns: 'people' })} } />{' '} - {t('send_message', {ns: 'people'})} + {' '} + {t('send_message', { ns: 'people' })}
)} diff --git a/jam-ui/src/components/sessions/JKSessionUser.js b/jam-ui/src/components/sessions/JKSessionUser.js index 5df8584c1..de23f9579 100644 --- a/jam-ui/src/components/sessions/JKSessionUser.js +++ b/jam-ui/src/components/sessions/JKSessionUser.js @@ -1,4 +1,4 @@ -import React, { useState } from 'react'; +import React, { useState, useCallback, useEffect } from 'react'; import { useSelector, useDispatch } from 'react-redux'; import { fetchPerson } from '../../store/features/peopleSlice'; import { useResponsive } from '@farfetch/react-context-responsive'; @@ -15,10 +15,21 @@ function JKSessionUser({ user }) { const [showSidePanel, setShowSidePanel] = useState(false); const { greaterThan } = useResponsive(); + const fetchPersonData = useCallback(async () => { + await dispatch(fetchPerson({ userId: user.id })).unwrap(); + }, [user.id]) + + useEffect(() => { + fetchPersonData(); + }, [user.id]) + + const toggleMoreDetails = async e => { e.preventDefault(); try { - await dispatch(fetchPerson({ userId: user.id })).unwrap(); + if(!userData){ + await fetchPersonData(); + } } catch (error) { console.log(error); } @@ -45,7 +56,7 @@ function JKSessionUser({ user }) {
- +
) : ( @@ -62,7 +73,7 @@ function JKSessionUser({ user }) { )} - + ); }