Merge pull request #68 from jedmund/fix-62

Fix #62: Descriptions showing up on other teams
This commit is contained in:
Justin Edmund 2022-12-27 08:31:42 -08:00 committed by GitHub
commit 265cab0527
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -66,11 +66,6 @@ const PartyDetails = (props: Props) => {
Visible: open, Visible: open,
}) })
const emptyClasses = classNames({
EmptyDetails: true,
Visible: true,
})
const userClass = classNames({ const userClass = classNames({
user: true, user: true,
empty: !party.user, empty: !party.user,
@ -110,9 +105,8 @@ const PartyDetails = (props: Props) => {
useEffect(() => { useEffect(() => {
// Extract the video IDs from the description // Extract the video IDs from the description
if (party.description) { if (appState.party.description) {
// sanitizeHtml(party.description) const videoIds = extractYoutubeVideoIds(appState.party.description)
const videoIds = extractYoutubeVideoIds(party.description)
// Fetch the video titles for each ID // Fetch the video titles for each ID
const fetchPromises = videoIds.map(({ id }) => fetchYoutubeData(id)) const fetchPromises = videoIds.map(({ id }) => fetchYoutubeData(id))
@ -124,10 +118,11 @@ const PartyDetails = (props: Props) => {
/https:\/\/www\.youtube\.com\/watch\?v=([\w-]+)/g /https:\/\/www\.youtube\.com\/watch\?v=([\w-]+)/g
// Replace the video URLs in the description with LiteYoutubeEmbed elements // Replace the video URLs in the description with LiteYoutubeEmbed elements
const newDescription = reactStringReplace( const newDescription = reactStringReplace(
party.description, appState.party.description,
youtubeUrlRegex, youtubeUrlRegex,
(match, i) => ( (match, i) => (
<LiteYouTubeEmbed <LiteYouTubeEmbed
key={`${match}-${i}`}
id={match} id={match}
title={videoTitles[i]} title={videoTitles[i]}
wrapperClass="YoutubeWrapper" wrapperClass="YoutubeWrapper"
@ -139,8 +134,10 @@ const PartyDetails = (props: Props) => {
// Update the state with the new description // Update the state with the new description
setEmbeddedDescription(newDescription) setEmbeddedDescription(newDescription)
}) })
} else {
setEmbeddedDescription('')
} }
}, [party.description]) }, [appState.party.description])
async function fetchYoutubeData(videoId: string) { async function fetchYoutubeData(videoId: string) {
return await youtube return await youtube