Fix crash of standalone wrapstodon and embedded status pages (#39400)
This commit is contained in:
parent
e2d44d8343
commit
ce8bf016bd
@ -5,6 +5,7 @@ import { Provider as ReduxProvider } from 'react-redux';
|
|||||||
import { importFetchedStatuses } from '@/mastodon/actions/importer';
|
import { importFetchedStatuses } from '@/mastodon/actions/importer';
|
||||||
import { hydrateStore } from '@/mastodon/actions/store';
|
import { hydrateStore } from '@/mastodon/actions/store';
|
||||||
import type { ApiAnnualReportResponse } from '@/mastodon/api/annual_report';
|
import type { ApiAnnualReportResponse } from '@/mastodon/api/annual_report';
|
||||||
|
import { FocusTargetProvider } from '@/mastodon/components/navigation_focus_target';
|
||||||
import { Router } from '@/mastodon/components/router';
|
import { Router } from '@/mastodon/components/router';
|
||||||
import { WrapstodonSharedPage } from '@/mastodon/features/annual_report/shared_page';
|
import { WrapstodonSharedPage } from '@/mastodon/features/annual_report/shared_page';
|
||||||
import { IntlProvider, loadLocale } from '@/mastodon/locales';
|
import { IntlProvider, loadLocale } from '@/mastodon/locales';
|
||||||
@ -52,7 +53,9 @@ function loaded() {
|
|||||||
<IntlProvider>
|
<IntlProvider>
|
||||||
<ReduxProvider store={store}>
|
<ReduxProvider store={store}>
|
||||||
<Router>
|
<Router>
|
||||||
<WrapstodonSharedPage />
|
<FocusTargetProvider>
|
||||||
|
<WrapstodonSharedPage />
|
||||||
|
</FocusTargetProvider>
|
||||||
</Router>
|
</Router>
|
||||||
</ReduxProvider>
|
</ReduxProvider>
|
||||||
</IntlProvider>,
|
</IntlProvider>,
|
||||||
|
|||||||
@ -102,15 +102,9 @@ export const FocusTargetProvider: React.FC<{
|
|||||||
export function useFocusOnNavigation(targetName?: string) {
|
export function useFocusOnNavigation(targetName?: string) {
|
||||||
const focusTargetRef = useContext(FocusTargetContext);
|
const focusTargetRef = useContext(FocusTargetContext);
|
||||||
|
|
||||||
if (focusTargetRef === null) {
|
|
||||||
throw Error(
|
|
||||||
'useFocusTargetContext must be used inside of a FocusTargetProvider',
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return useCallback(
|
return useCallback(
|
||||||
(element: HTMLElement | null) => {
|
(element: HTMLElement | null) => {
|
||||||
const focusTarget = focusTargetRef.current;
|
const focusTarget = focusTargetRef?.current;
|
||||||
|
|
||||||
// Bail out if focusTarget was set to `false`
|
// Bail out if focusTarget was set to `false`
|
||||||
if (!element || !focusTarget) {
|
if (!element || !focusTarget) {
|
||||||
|
|||||||
@ -8,6 +8,7 @@ import { Provider } from 'react-redux';
|
|||||||
|
|
||||||
import { fetchStatus, toggleStatusSpoilers } from 'mastodon/actions/statuses';
|
import { fetchStatus, toggleStatusSpoilers } from 'mastodon/actions/statuses';
|
||||||
import { hydrateStore } from 'mastodon/actions/store';
|
import { hydrateStore } from 'mastodon/actions/store';
|
||||||
|
import { FocusTargetProvider } from 'mastodon/components/navigation_focus_target';
|
||||||
import { Router } from 'mastodon/components/router';
|
import { Router } from 'mastodon/components/router';
|
||||||
import { DetailedStatus } from 'mastodon/features/status/components/detailed_status';
|
import { DetailedStatus } from 'mastodon/features/status/components/detailed_status';
|
||||||
import { useRenderSignal } from 'mastodon/hooks/useRenderSignal';
|
import { useRenderSignal } from 'mastodon/hooks/useRenderSignal';
|
||||||
@ -79,7 +80,9 @@ export const Status: React.FC<{ id: string }> = ({ id }) => {
|
|||||||
<IntlProvider>
|
<IntlProvider>
|
||||||
<Provider store={store}>
|
<Provider store={store}>
|
||||||
<Router>
|
<Router>
|
||||||
<Embed id={id} />
|
<FocusTargetProvider>
|
||||||
|
<Embed id={id} />
|
||||||
|
</FocusTargetProvider>
|
||||||
</Router>
|
</Router>
|
||||||
</Provider>
|
</Provider>
|
||||||
</IntlProvider>
|
</IntlProvider>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user