From 037bf858c09cdefc2005e1f106a1b80fb8021f3e Mon Sep 17 00:00:00 2001 From: "plebeius.eth" Date: Sat, 9 Sep 2023 11:02:23 +0200 Subject: [PATCH 1/6] memoize VerifiedAuthor --- src/components/VerifiedAuthor.jsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/components/VerifiedAuthor.jsx b/src/components/VerifiedAuthor.jsx index 5a832381..6f54c593 100644 --- a/src/components/VerifiedAuthor.jsx +++ b/src/components/VerifiedAuthor.jsx @@ -1,3 +1,4 @@ +import React from 'react'; import {useComment, useAuthorAddress} from '@plebbit/plebbit-react-hooks'; function VerifiedAuthor({ commentCid, children }) { @@ -7,4 +8,4 @@ function VerifiedAuthor({ commentCid, children }) { return children({ authorAddress, shortAuthorAddress }); } -export default VerifiedAuthor; \ No newline at end of file +export default React.memo(VerifiedAuthor); \ No newline at end of file From 232d869fc82d7abea8221c9f382faac4a5feefdb Mon Sep 17 00:00:00 2001 From: "plebeius.eth" Date: Sat, 9 Sep 2023 17:09:09 +0200 Subject: [PATCH 2/6] fix embedded media, add new sites --- src/components/Embed.jsx | 259 +++++++++++++++++++ src/components/styled/GlobalStyle.styled.jsx | 45 +++- src/components/views/Board.jsx | 180 +++++++------ src/utils/getCommentMediaInfo.js | 45 +--- yarn.lock | 186 +------------ 5 files changed, 412 insertions(+), 303 deletions(-) create mode 100644 src/components/Embed.jsx diff --git a/src/components/Embed.jsx b/src/components/Embed.jsx new file mode 100644 index 00000000..5629c2e7 --- /dev/null +++ b/src/components/Embed.jsx @@ -0,0 +1,259 @@ +const Embed = ({url}) => { + const parsedUrl = new URL(url); + + if (youtubeHosts.has(parsedUrl.host)) { + return ; + } + if (twitterHosts.has(parsedUrl.host)) { + return ; + } + if (redditHosts.has(parsedUrl.host)) { + return ; + } + if (twitchHosts.has(parsedUrl.host)) { + return ; + } + if (tiktokHosts.has(parsedUrl.host)) { + return ; + } + if (instagramHosts.has(parsedUrl.host)) { + return ; + } + if (odyseeHosts.has(parsedUrl.host)) { + return ; + } + if (bitchuteHosts.has(parsedUrl.host)) { + return ; + } + if (streamableHosts.has(parsedUrl.host)) { + return ; + } + if (spotifyHosts.has(parsedUrl.host)) { + return ; + } +}; + +const youtubeHosts = new Set(['youtube.com', 'www.youtube.com', 'youtu.be', 'www.youtu.be']); + +const YoutubeEmbed = ({parsedUrl}) => { + let youtubeId; + if (parsedUrl.host.endsWith('youtu.be')) { + youtubeId = parsedUrl.pathname.replaceAll('/', ''); + } + else { + youtubeId = parsedUrl.searchParams.get('v'); + } + return