From 3db6d0c0241abf7d7969d072fc493d8cdc146af6 Mon Sep 17 00:00:00 2001 From: Kieran Date: Thu, 19 Jan 2023 19:59:37 +0000 Subject: [PATCH] bug: always inject script --- src/Element/TidalEmbed.tsx | 24 ++++++------------------ 1 file changed, 6 insertions(+), 18 deletions(-) diff --git a/src/Element/TidalEmbed.tsx b/src/Element/TidalEmbed.tsx index 51e12289..197d7031 100644 --- a/src/Element/TidalEmbed.tsx +++ b/src/Element/TidalEmbed.tsx @@ -2,11 +2,6 @@ import { useEffect, useMemo } from "react"; import { TidalRegex } from "../Const"; const TidalEmbed = ({ link }: { link: string }) => { - // https://tidal.com/browse/mix/0029457ec7eed3b340ee2b907fc4d8 - // https://tidal.com/browse/track/168295350 - // https://tidal.com/browse/album/168295347 - // https://tidal.com/browse/playlist/4261748a-4287-4758-aaab-6d5be3e99e52 - const data = useMemo(() => { const match = link.match(TidalRegex); if (match?.length != 3) { @@ -19,21 +14,14 @@ const TidalEmbed = ({ link }: { link: string }) => { const ScriptSrc = "https://embed.tidal.com/tidal-embed.js"; useEffect(() => { - let head = document.head.querySelector(`script[src="${ScriptSrc}"]`); - console.debug(head); - if (!head) { - let sTag = document.createElement("script"); - sTag.src = ScriptSrc; - sTag.async = true; - document.head.appendChild(sTag); - } + let sTag = document.createElement("script"); + sTag.src = ScriptSrc; + sTag.async = true; + document.head.appendChild(sTag); }, []); - return ( - <> -
- - ) + if (!data) return null; + return
; } export default TidalEmbed; \ No newline at end of file