Skip to content

Commit

Permalink
Merge branch 'stable' into checklist
Browse files Browse the repository at this point in the history
  • Loading branch information
davidmz authored Jul 31, 2023
2 parents 0104330 + 3a2048c commit 3ae9d69
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 14 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
14 changes: 7 additions & 7 deletions src/components/link-preview/embedly.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 4 additions & 1 deletion src/components/link-preview/telegram.jsx
Original file line number Diff line number Diff line change
@@ -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';

Expand All @@ -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 (
<FoldableContent>
<div className="telegram-preview link-preview-content">
<iframe
src={`${baseURL}?embed=1`}
src={`${baseURL}?embed=1&dark=${isDarkTheme ? '1' : '0'}`}
data-url={baseURL}
frameBorder="0"
scrolling="no"
Expand Down
4 changes: 2 additions & 2 deletions src/components/signin.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import ErrorBoundary from './error-boundary';
import { FieldsetWrapper } from './fieldset-wrapper';
import { Throbber } from './throbber';
import { providerTitle, useExtAuthProviders } from './ext-auth-helpers';
import { CookiesBanner } from './cookies-banner';
import { CookiesWarning } from './cookies-warning';
import { ExtAuthButtons } from './ext-auth-buttons';
import UserName from './user-name';

Expand Down Expand Up @@ -40,7 +40,7 @@ export default memo(function SignInPage() {
) : null}
<div className="col-md-12">
<h2 className="p-signin-header">Sign in</h2>
<CookiesBanner />
<CookiesWarning />
<ErrorBoundary>
<SignInForm />
<ResumeForm />
Expand Down
4 changes: 2 additions & 2 deletions src/components/signup.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { Link } from 'react-router';

import { signedIn } from '../redux/action-creators';
import SignupForm from './signup-form';
import { CookiesBanner } from './cookies-banner';
import { CookiesWarning } from './cookies-warning';
import { useExtAuthProviders, providerTitle } from './ext-auth-helpers';
import { ExtAuthButtons, SIGN_UP } from './ext-auth-buttons';
import { useServerInfo } from './hooks/server-info';
Expand Down Expand Up @@ -54,7 +54,7 @@ export default memo(function Signup() {
<h2 className="p-signin-header">Sign up</h2>
{showSignUpForm ? (
<>
<CookiesBanner />
<CookiesWarning />
<SignupForm />
<ExtAuthSignup />
</>
Expand Down
2 changes: 1 addition & 1 deletion test/jest/__snapshots__/link-preview.test.jsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ exports[`LinkPreview > Shows a Telegram preview 1`] = `
data-url="https://t.me/meowdobot/0000"
frameborder="0"
scrolling="no"
src="https://t.me/meowdobot/0000?embed=1"
src="https://t.me/meowdobot/0000?embed=1&dark=0"
style="height: 0px;"
/>
</div>
Expand Down

0 comments on commit 3ae9d69

Please sign in to comment.