From 8d5b4cb86a1c4ae71d5e8807f83acdaee62d40d7 Mon Sep 17 00:00:00 2001 From: Cam Kemshal-Bell Date: Mon, 4 Nov 2024 09:23:13 +1100 Subject: [PATCH] fix: remove tweet oEmbed previews --- app/Services/MetaData.php | 17 ----------------- resources/js/theme-switch.js | 17 ----------------- .../components/link-preview-card.blade.php | 13 +++---------- .../views/layouts/components/head.blade.php | 2 -- 4 files changed, 3 insertions(+), 46 deletions(-) diff --git a/app/Services/MetaData.php b/app/Services/MetaData.php index f4fefd2bf..d5f347c7d 100644 --- a/app/Services/MetaData.php +++ b/app/Services/MetaData.php @@ -130,23 +130,6 @@ private function parse(string $content): Collection } } - if ($data->has('site_name') && $data->get('site_name') === 'X (formerly Twitter)') { - $x = $this->fetchOEmbed( - service: 'https://publish.twitter.com/oembed', - options: [ - 'dnt' => 'true', - 'omit_script' => 'true', - 'hide_thread' => 'true', - 'maxwidth' => '446', - 'maxheight' => '251', - ]); - if ($x->isNotEmpty()) { - foreach ($x as $key => $value) { - $data->put($key, $value); - } - } - } - if ($data->has('site_name') && $data->get('site_name') === 'Vimeo') { $vimeo = $this->fetchOEmbed( service: 'https://vimeo.com/api/oembed.json', diff --git a/resources/js/theme-switch.js b/resources/js/theme-switch.js index 58e5d2b07..8a3e300bc 100644 --- a/resources/js/theme-switch.js +++ b/resources/js/theme-switch.js @@ -36,23 +36,6 @@ const themeSwitch = () => ({ if (this.currentTheme !== newTheme) { this.currentTheme = newTheme; - this.renderTweets(newTheme); - } - }, - - renderTweets(theme) { - const tweetContainers = document.querySelectorAll('div[data-tweet-id]'); - - if (tweetContainers.length > 0) { - tweetContainers.forEach(container => { - container.innerHTML = ''; - - window.twttr.widgets.createTweet(container.dataset.tweetId, container, { - theme: theme, - conversation: 'none', - align: 'center', - }); - }); } }, }); diff --git a/resources/views/components/link-preview-card.blade.php b/resources/views/components/link-preview-card.blade.php index a800c8383..16521bc49 100644 --- a/resources/views/components/link-preview-card.blade.php +++ b/resources/views/components/link-preview-card.blade.php @@ -4,16 +4,9 @@ class="mx-auto mt-2 min-w-full group/preview" data-navigate-ignore="true" > @if ($data->has('html')) - @if ($data->get('site_name') === 'X (formerly Twitter)') - @php($tweetId = explode('/', $url)) -
- {!! $data->get('html') !!} -
- @else -
- {!! $data->get('html') !!} -
- @endif +
+ {!! $data->get('html') !!} +
@elseif($data->has('image')) @php($shortUrl = parse_url($url)['host']) diff --git a/resources/views/layouts/components/head.blade.php b/resources/views/layouts/components/head.blade.php index 9c0ccd4a6..7d3d00a69 100644 --- a/resources/views/layouts/components/head.blade.php +++ b/resources/views/layouts/components/head.blade.php @@ -207,8 +207,6 @@ } - -