Merge pull request #68 from jedmund/fix-62
Fix #62: Descriptions showing up on other teams
This commit is contained in:
commit
265cab0527
1 changed files with 7 additions and 10 deletions
|
|
@ -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
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue