Disabled Youtube code for now
This commit is contained in:
parent
63846089a4
commit
277a248ba1
1 changed files with 24 additions and 26 deletions
|
|
@ -59,38 +59,36 @@ const PartyFooter = (props: Props) => {
|
||||||
useState<React.ReactNode>()
|
useState<React.ReactNode>()
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
// Extract the video IDs from the description
|
|
||||||
if (partySnapshot.description) {
|
if (partySnapshot.description) {
|
||||||
const videoIds = extractYoutubeVideoIds(partySnapshot.description)
|
const purified = DOMPurify.sanitize(partySnapshot.description)
|
||||||
|
setSanitizedDescription(purified)
|
||||||
// Fetch the video titles for each ID
|
|
||||||
const fetchPromises = videoIds.map(({ id }) => fetchYoutubeData(id))
|
|
||||||
|
|
||||||
// Wait for all the video titles to be fetched
|
|
||||||
Promise.all(fetchPromises).then((videoTitles) => {
|
|
||||||
// Replace the video URLs in the description with LiteYoutubeEmbed elements
|
|
||||||
const newDescription = reactStringReplace(
|
|
||||||
partySnapshot.description,
|
|
||||||
youtubeUrlRegex,
|
|
||||||
(match, i) => (
|
|
||||||
<LiteYouTubeEmbed
|
|
||||||
key={`${match}-${i}`}
|
|
||||||
id={match}
|
|
||||||
title={videoTitles[i]}
|
|
||||||
wrapperClass={styles.youtube}
|
|
||||||
playerClass={styles.playerButton}
|
|
||||||
/>
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
// Update the state with the new description
|
|
||||||
setEmbeddedDescription(newDescription)
|
|
||||||
})
|
|
||||||
} else {
|
} else {
|
||||||
setEmbeddedDescription('')
|
setEmbeddedDescription('')
|
||||||
}
|
}
|
||||||
}, [partySnapshot.description])
|
}, [partySnapshot.description])
|
||||||
|
|
||||||
|
// Extract the video IDs from the description
|
||||||
|
// const videoIds = extractYoutubeVideoIds(partySnapshot.description)
|
||||||
|
// Fetch the video titles for each ID
|
||||||
|
// const fetchPromises = videoIds.map(({ id }) => fetchYoutubeData(id))
|
||||||
|
// // Wait for all the video titles to be fetched
|
||||||
|
// Promise.all(fetchPromises).then((videoTitles) => {
|
||||||
|
// // Replace the video URLs in the description with LiteYoutubeEmbed elements
|
||||||
|
// const newDescription = reactStringReplace(
|
||||||
|
// partySnapshot.description,
|
||||||
|
// youtubeUrlRegex,
|
||||||
|
// (match, i) => (
|
||||||
|
// <LiteYouTubeEmbed
|
||||||
|
// key={`${match}-${i}`}
|
||||||
|
// id={match}
|
||||||
|
// title={videoTitles[i]}
|
||||||
|
// wrapperClass={styles.youtube}
|
||||||
|
// playerClass={styles.playerButton}
|
||||||
|
// />
|
||||||
|
// )
|
||||||
|
// )
|
||||||
|
// Update the state with the new description
|
||||||
|
|
||||||
async function fetchYoutubeData(videoId: string) {
|
async function fetchYoutubeData(videoId: string) {
|
||||||
return await youtube
|
return await youtube
|
||||||
.getVideoById(videoId, { maxResults: 1 })
|
.getVideoById(videoId, { maxResults: 1 })
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue