[Glitch] Fix crash of standalone wrapstodon and embedded status pages
Port a78d1150a9c8f385450bb0cfaa947c164c8c69d6 to glitch-soc Signed-off-by: Claire <claire.github-309c@sitedethib.com>
This commit is contained in:
parent
6aca68e185
commit
81aaac4779
@ -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) {
|
||||||
|
|||||||
@ -5,6 +5,7 @@ import { Provider as ReduxProvider } from 'react-redux';
|
|||||||
import { importFetchedStatuses } from '@/flavours/glitch/actions/importer';
|
import { importFetchedStatuses } from '@/flavours/glitch/actions/importer';
|
||||||
import { hydrateStore } from '@/flavours/glitch/actions/store';
|
import { hydrateStore } from '@/flavours/glitch/actions/store';
|
||||||
import type { ApiAnnualReportResponse } from '@/flavours/glitch/api/annual_report';
|
import type { ApiAnnualReportResponse } from '@/flavours/glitch/api/annual_report';
|
||||||
|
import { FocusTargetProvider } from '@/flavours/glitch/components/navigation_focus_target';
|
||||||
import { Router } from '@/flavours/glitch/components/router';
|
import { Router } from '@/flavours/glitch/components/router';
|
||||||
import { WrapstodonSharedPage } from '@/flavours/glitch/features/annual_report/shared_page';
|
import { WrapstodonSharedPage } from '@/flavours/glitch/features/annual_report/shared_page';
|
||||||
import { IntlProvider, loadLocale } from '@/flavours/glitch/locales';
|
import { IntlProvider, loadLocale } from '@/flavours/glitch/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>,
|
||||||
|
|||||||
@ -11,6 +11,7 @@ import {
|
|||||||
toggleStatusSpoilers,
|
toggleStatusSpoilers,
|
||||||
} from 'flavours/glitch/actions/statuses';
|
} from 'flavours/glitch/actions/statuses';
|
||||||
import { hydrateStore } from 'flavours/glitch/actions/store';
|
import { hydrateStore } from 'flavours/glitch/actions/store';
|
||||||
|
import { FocusTargetProvider } from 'flavours/glitch/components/navigation_focus_target';
|
||||||
import { Router } from 'flavours/glitch/components/router';
|
import { Router } from 'flavours/glitch/components/router';
|
||||||
import { DetailedStatus } from 'flavours/glitch/features/status/components/detailed_status';
|
import { DetailedStatus } from 'flavours/glitch/features/status/components/detailed_status';
|
||||||
import { useRenderSignal } from 'flavours/glitch/hooks/useRenderSignal';
|
import { useRenderSignal } from 'flavours/glitch/hooks/useRenderSignal';
|
||||||
@ -86,7 +87,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