From ad0f1c3393175ac5c7708e6134bc603448cd7cee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?nicole=20miko=C5=82ajczyk?= Date: Sun, 19 Oct 2025 19:48:52 +0200 Subject: [PATCH] pl-fe: we don't advertise the embed feature, it's too heavy done this way anyway MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: nicole mikołajczyk --- packages/pl-fe/src/actions/compose.ts | 14 ---- packages/pl-fe/src/components/ui/banner.tsx | 25 ------- .../src/features/embedded-status/index.tsx | 73 ------------------- packages/pl-fe/src/features/ui/index.tsx | 6 +- packages/pl-fe/src/iframe.ts | 14 ---- packages/pl-fe/src/init/pl-fe-mount.tsx | 51 ++++--------- 6 files changed, 18 insertions(+), 165 deletions(-) delete mode 100644 packages/pl-fe/src/components/ui/banner.tsx delete mode 100644 packages/pl-fe/src/features/embedded-status/index.tsx delete mode 100644 packages/pl-fe/src/iframe.ts diff --git a/packages/pl-fe/src/actions/compose.ts b/packages/pl-fe/src/actions/compose.ts index 83a01d83b..b84a066a7 100644 --- a/packages/pl-fe/src/actions/compose.ts +++ b/packages/pl-fe/src/actions/compose.ts @@ -298,19 +298,6 @@ const directCompose = (account: ComposeDirectAction['account']) => useModalsStore.getState().openModal('COMPOSE'); }; -const directComposeById = (accountId: string) => - (dispatch: AppDispatch, getState: () => RootState) => { - const account = selectAccount(getState(), accountId); - if (!account) return; - - dispatch({ - type: COMPOSE_DIRECT, - composeId: 'compose-modal', - account, - }); - useModalsStore.getState().openModal('COMPOSE'); - }; - const handleComposeSubmit = (dispatch: AppDispatch, getState: () => RootState, composeId: string, data: BaseStatus | ScheduledStatus, status: string, edit?: boolean, redact?: boolean) => { if (!dispatch || !getState) return; @@ -1153,7 +1140,6 @@ export { resetCompose, mentionCompose, directCompose, - directComposeById, submitCompose, uploadFile, uploadCompose, diff --git a/packages/pl-fe/src/components/ui/banner.tsx b/packages/pl-fe/src/components/ui/banner.tsx deleted file mode 100644 index d5af88779..000000000 --- a/packages/pl-fe/src/components/ui/banner.tsx +++ /dev/null @@ -1,25 +0,0 @@ -import clsx from 'clsx'; -import React from 'react'; - -interface IBanner { - theme: 'frosted' | 'opaque'; - children: React.ReactNode; - className?: string; -} - -/** Displays a sticky full-width banner at the bottom of the screen. */ -const Banner: React.FC = ({ theme, children, className }) => ( -
-
- {children} -
-
-); - -export { Banner as default }; diff --git a/packages/pl-fe/src/features/embedded-status/index.tsx b/packages/pl-fe/src/features/embedded-status/index.tsx deleted file mode 100644 index 027ee0f4f..000000000 --- a/packages/pl-fe/src/features/embedded-status/index.tsx +++ /dev/null @@ -1,73 +0,0 @@ -import React, { useCallback, useEffect, useState } from 'react'; -import { useIntl } from 'react-intl'; -import { useHistory } from 'react-router-dom'; - -import { fetchStatus } from 'pl-fe/actions/statuses'; -import MissingIndicator from 'pl-fe/components/missing-indicator'; -import Status from 'pl-fe/components/status'; -import Spinner from 'pl-fe/components/ui/spinner'; -import { useAppDispatch } from 'pl-fe/hooks/use-app-dispatch'; -import { useAppSelector } from 'pl-fe/hooks/use-app-selector'; -import { iframeId } from 'pl-fe/iframe'; -import { makeGetStatus } from 'pl-fe/selectors'; - -interface IEmbeddedStatus { - params: { - statusId: string; - }; -} - -/** Status to be presented in an iframe for embeds on external websites. */ -const EmbeddedStatus: React.FC = ({ params }) => { - const dispatch = useAppDispatch(); - const history = useHistory(); - const getStatus = useCallback(makeGetStatus(), []); - const intl = useIntl(); - - const status = useAppSelector(state => getStatus(state, { id: params.statusId })); - - const [loading, setLoading] = useState(true); - - useEffect(() => { - // Prevent navigation for UX and security. - // https://stackoverflow.com/a/71531211 - history.block(); - - dispatch(fetchStatus(params.statusId, intl)) - .then(() => setLoading(false)) - .catch(() => setLoading(false)); - }, []); - - useEffect(() => { - window.parent.postMessage({ - type: 'setHeight', - id: iframeId, - height: document.getElementsByTagName('html')[0].scrollHeight, - }, '*'); - }, [status, loading]); - - const renderInner = () => { - if (loading) { - return ; - } else if (status) { - return ; - } else { - return ; - } - }; - - return ( - e.stopPropagation()} - target='_blank' - > -
- {renderInner()} -
-
- ); -}; - -export { EmbeddedStatus as default }; diff --git a/packages/pl-fe/src/features/ui/index.tsx b/packages/pl-fe/src/features/ui/index.tsx index dcaff44a8..4841d6ab8 100644 --- a/packages/pl-fe/src/features/ui/index.tsx +++ b/packages/pl-fe/src/features/ui/index.tsx @@ -170,7 +170,7 @@ const SwitchingColumnsArea: React.FC = React.memo(({ chil const { isLoggedIn } = useLoggedIn(); const standalone = useAppSelector(isStandalone); - const { authenticatedProfile, cryptoAddresses } = usePlFeConfig(); + const { authenticatedProfile, cryptoAddresses, redirectRootNoLogin } = usePlFeConfig(); const hasCrypto = cryptoAddresses.length > 0; // NOTE: Mastodon and Pleroma route some basenames to the backend. @@ -180,6 +180,10 @@ const SwitchingColumnsArea: React.FC = React.memo(({ chil // Ex: use /login instead of /auth, but redirect /auth to /login return ( + {(!isLoggedIn && redirectRootNoLogin) && ( + + )} + {standalone && !isLoggedIn && (WITH_LANDING_PAGE ? : )} diff --git a/packages/pl-fe/src/iframe.ts b/packages/pl-fe/src/iframe.ts deleted file mode 100644 index ae4893bc4..000000000 --- a/packages/pl-fe/src/iframe.ts +++ /dev/null @@ -1,14 +0,0 @@ -/** ID of this iframe (given by embed.js) when embedded on a page. */ -let iframeId: string; - -/** Receive iframe messages. */ -// https://github.com/mastodon/mastodon/pull/4853 -const handleMessage = (e: MessageEvent) => { - if (e.data?.type === 'setHeight') { - iframeId = e.data?.id; - } -}; - -window.addEventListener('message', handleMessage); - -export { iframeId }; diff --git a/packages/pl-fe/src/init/pl-fe-mount.tsx b/packages/pl-fe/src/init/pl-fe-mount.tsx index c1afd6181..ac2d02bcc 100644 --- a/packages/pl-fe/src/init/pl-fe-mount.tsx +++ b/packages/pl-fe/src/init/pl-fe-mount.tsx @@ -1,6 +1,6 @@ import React, { Suspense } from 'react'; import { Toaster } from 'react-hot-toast'; -import { BrowserRouter, Switch, Redirect, Route } from 'react-router-dom'; +import { BrowserRouter } from 'react-router-dom'; import { CompatRouter } from 'react-router-dom-v5-compat'; // @ts-ignore: it doesn't have types import { ScrollContext } from 'react-router-scroll-4'; @@ -9,22 +9,14 @@ import * as BuildConfig from 'pl-fe/build-config'; import LoadingScreen from 'pl-fe/components/loading-screen'; import SiteErrorBoundary from 'pl-fe/components/site-error-boundary'; import { ModalRoot } from 'pl-fe/features/ui/util/async-components'; -import { useLoggedIn } from 'pl-fe/hooks/use-logged-in'; -import { usePlFeConfig } from 'pl-fe/hooks/use-pl-fe-config'; import { useCachedLocationHandler } from 'pl-fe/utils/redirect'; -const EmbeddedStatus = React.lazy(() => import('pl-fe/features/embedded-status')); const UI = React.lazy(() => import('pl-fe/features/ui')); /** Highest level node with the Redux store. */ const PlFeMount = () => { useCachedLocationHandler(); - const { isLoggedIn } = useLoggedIn(); - const plFeConfig = usePlFeConfig(); - - const { redirectRootNoLogin } = plFeConfig; - // @ts-ignore: I don't actually know what these should be, lol const shouldUpdateScroll = (prevRouterProps, { location }) => !(location.state?.plFeModalKey && location.state?.plFeModalKey !== prevRouterProps?.location?.state?.plFeModalKey) @@ -35,37 +27,20 @@ const PlFeMount = () => { - - {(!isLoggedIn && redirectRootNoLogin) && ( - - )} + <> + }> + + - ( - - - - )} + + + + + - - - - - }> - - - - - - - - - - +