Make /timeline/local link still work

merge-requests/3340/head
Alex Gleason 2025-03-02 12:57:44 -06:00
rodzic 9dc980a384
commit 3bba1389bc
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 7211D1F99744FBB7
2 zmienionych plików z 14 dodań i 8 usunięć

Wyświetl plik

@ -1,5 +1,6 @@
import { useState, Suspense } from 'react'; import { Suspense } from 'react';
import { FormattedMessage } from 'react-intl'; import { FormattedMessage } from 'react-intl';
import { Route, Switch, useRouteMatch } from 'react-router-dom';
import Tabs from 'soapbox/components/ui/tabs.tsx'; import Tabs from 'soapbox/components/ui/tabs.tsx';
import { CommunityTimeline, FollowsTimeline } from 'soapbox/features/ui/util/async-components.ts'; import { CommunityTimeline, FollowsTimeline } from 'soapbox/features/ui/util/async-components.ts';
@ -8,7 +9,8 @@ import { useInstance } from 'soapbox/hooks/useInstance.ts';
const HomeTimeline = () => { const HomeTimeline = () => {
const { instance } = useInstance(); const { instance } = useInstance();
const [activeTab, setActiveTab] = useState('follows');
const match = useRouteMatch();
const notifications = useAppSelector((state) => state.notificationsTab); const notifications = useAppSelector((state) => state.notificationsTab);
return ( return (
@ -16,23 +18,26 @@ const HomeTimeline = () => {
<Tabs <Tabs
items={[ items={[
{ {
name: 'follows', to: '/',
name: '/',
text: <FormattedMessage id='tabs_bar.follows' defaultMessage='Follows' />, text: <FormattedMessage id='tabs_bar.follows' defaultMessage='Follows' />,
action: () => setActiveTab('follows'),
notification: notifications.home, notification: notifications.home,
}, },
{ {
name: 'local', to: '/timeline/local',
name: '/timeline/local',
text: <div className='block max-w-xs truncate'>{instance.title}</div>, text: <div className='block max-w-xs truncate'>{instance.title}</div>,
action: () => setActiveTab('local'),
notification: notifications.instance, notification: notifications.instance,
}, },
]} ]}
activeItem={activeTab} activeItem={match.path}
/> />
<Suspense fallback={<div className='p-4 text-center'><FormattedMessage id='loading_indicator.label' defaultMessage='Loading…' /></div>}> <Suspense fallback={<div className='p-4 text-center'><FormattedMessage id='loading_indicator.label' defaultMessage='Loading…' /></div>}>
{activeTab === 'follows' ? <FollowsTimeline /> : <CommunityTimeline />} <Switch>
<Route path='/' exact component={FollowsTimeline} />
<Route path='/timeline/local' exact component={CommunityTimeline} />
</Switch>
</Suspense> </Suspense>
</> </>
); );

Wyświetl plik

@ -192,6 +192,7 @@ const SwitchingColumnsArea: React.FC<ISwitchingColumnsArea> = ({ children }) =>
NOTE: we cannot nest routes in a fragment NOTE: we cannot nest routes in a fragment
https://stackoverflow.com/a/68637108 https://stackoverflow.com/a/68637108
*/} */}
{features.federating && <WrappedRoute path='/timeline/local' exact page={HomePage} component={HomeTimeline} content={children} publicRoute />}
{features.federating && <WrappedRoute path='/timeline/global' exact page={HomePage} component={PublicTimeline} content={children} publicRoute />} {features.federating && <WrappedRoute path='/timeline/global' exact page={HomePage} component={PublicTimeline} content={children} publicRoute />}
{features.federating && <WrappedRoute path='/timeline/:instance' exact page={RemoteInstancePage} component={RemoteTimeline} content={children} publicRoute />} {features.federating && <WrappedRoute path='/timeline/:instance' exact page={RemoteInstancePage} component={RemoteTimeline} content={children} publicRoute />}