diff --git a/CHANGELOG.md b/CHANGELOG.md index fbdc82738..7a6bca3a2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 For other users, a fixed-width text representation of the checkbox is shown: "[ ]" or "[🗸]". +### Fixed +- Telegram previews now supports dark theme ## [1.121.1] - 2023-07-15 ### Fixed diff --git a/src/components/cookies-banner.jsx b/src/components/cookies-warning.jsx similarity index 97% rename from src/components/cookies-banner.jsx rename to src/components/cookies-warning.jsx index c2dae3a83..cfdc1f33d 100644 --- a/src/components/cookies-banner.jsx +++ b/src/components/cookies-warning.jsx @@ -2,7 +2,7 @@ import { useSubscription } from 'use-subscription'; import { cookiesEnabled } from '../services/feat-detection'; -export function CookiesBanner() { +export function CookiesWarning() { const enabled = useSubscription(cookiesEnabledSub); return ( diff --git a/src/components/link-preview/embedly.jsx b/src/components/link-preview/embedly.jsx index 636a974d1..30cc713ae 100644 --- a/src/components/link-preview/embedly.jsx +++ b/src/components/link-preview/embedly.jsx @@ -35,19 +35,19 @@ export default memo(function EmbedlyPreview({ url }) { ); }); -let embedlyInitialized = false; function initEmbedly() { - if (embedlyInitialized) { - return; - } - embedlyInitialized = true; - const id = 'embedly-platform'; if (document.querySelector(`#${id}`)) { return; } window.embedly = - window.embedly || ((...args) => (window.embedly.q = window.embedly.q || []).push(args)); + window.embedly || + // We have to use the classic 'function()' here (rather than an arrow + // function) because of the way Embedly detects the type of this variable. + function (...args) { + (window.embedly.q = window.embedly.q || []).push(args); + }; + const script = document.createElement('script'); script.id = id; script.async = true; diff --git a/src/components/link-preview/telegram.jsx b/src/components/link-preview/telegram.jsx index ab31fbf6e..5ad0a9f3e 100644 --- a/src/components/link-preview/telegram.jsx +++ b/src/components/link-preview/telegram.jsx @@ -1,6 +1,8 @@ import { useEffect } from 'react'; import { once } from 'lodash-es'; +import { useSelector } from 'react-redux'; +import { darkTheme } from '../select-utils'; import * as heightCache from './helpers/size-cache'; import FoldableContent from './helpers/foldable-content'; @@ -12,13 +14,14 @@ export function canShowURL(url) { export default function TelegramPreview({ url }) { useEffect(() => void startEventListening(), []); + const isDarkTheme = useSelector(darkTheme); const [baseURL] = url.match(TG_POST_RE); return (