[Glitch] Fix /deck being removed from path when resizing window

Port 0a005ddcd5957f60dde0951ab4c7a94e27d1c9a5 to glitch-soc

Signed-off-by: Claire <claire.github-309c@sitedethib.com>
This commit is contained in:
Claire committed 2026-08-20 19:05:09 +02:00
1 parent ca37348b7e
commit 9df479f073
3 files changed
+10 -7

No files matched your search

@@ -11,9 +11,10 @@ import type {
} from 'history';
import { createBrowserHistory } from 'history';
import { layoutFromWindow } from 'flavours/glitch/is_mobile';
import { isDevelopment } from 'flavours/glitch/utils/environment';
import { forceSingleColumn, hasMultiColumnPath } from '../initial_state';
import type { FocusTarget } from './navigation_focus_target';
interface MastodonLocationState {
@@ -63,7 +64,8 @@ function normalizePath(
}
if (
layoutFromWindow() === 'multi-column' &&
!forceSingleColumn &&
hasMultiColumnPath &&
location.pathname &&
!location.pathname.startsWith('/deck')
) {
@@ -23,7 +23,7 @@ import { HoverCardController } from 'flavours/glitch/components/hover_card_contr
import { Permalink } from 'flavours/glitch/components/permalink';
import { PictureInPicture } from 'flavours/glitch/features/picture_in_picture';
import { identityContextPropShape, withIdentity } from 'flavours/glitch/identity_context';
import { layoutFromWindow } from 'flavours/glitch/is_mobile';
import { layoutFromWindow, transientSingleColumn } from 'flavours/glitch/is_mobile';
import { selectUnreadNotificationGroupsCount } from 'flavours/glitch/selectors/notifications';
import { WithRouterPropTypes } from 'flavours/glitch/utils/react_router';
import { checkAnnualReport } from '@/flavours/glitch/reducers/slices/annual_report';
@@ -32,7 +32,7 @@ import { uploadCompose, resetCompose, changeComposeSpoilerness } from '../../act
import { clearHeight } from '../../actions/height_cache';
import { fetchServer, fetchServerTranslationLanguages } from '../../actions/server';
import { expandHomeTimeline } from '../../actions/timelines';
import { initialState, me, owner, singleUserMode, trendsEnabled, landingPage, localLiveFeedAccess, disableHoverCards, domain } from '../../initial_state';
import { initialState, forceSingleColumn, me, owner, singleUserMode, trendsEnabled, landingPage, localLiveFeedAccess, disableHoverCards, domain } from '../../initial_state';
import BundleColumnError from './components/bundle_column_error';
import { NavigationBar } from './components/navigation_bar';
@@ -198,8 +198,8 @@ class SwitchingColumnsArea extends PureComponent {
<WrappedSwitch>
<Redirect from='/' to={{pathname: rootRedirect, state: {...this.props.location.state, focusTarget: false}}} exact />
{singleColumn ? <Redirect from='/deck' to='/home' exact /> : null}
{singleColumn && pathName.startsWith('/deck/') ? <Redirect from={pathName} to={{...this.props.location, pathname: pathName.slice(5)}} /> : null}
{forceSingleColumn || transientSingleColumn ? <Redirect from='/deck' to='/home' exact /> : null}
{(forceSingleColumn || transientSingleColumn) && pathName.startsWith('/deck/') ? <Redirect from={pathName} to={{...this.props.location, pathname: pathName.slice(5)}} /> : null}
{/* Redirect old bookmarks (without /deck) with home-like routes to the advanced interface */}
{!singleColumn && pathName === '/home' ? <Redirect from='/home' to='/deck/getting-started' exact /> : null}
{pathName === '/getting-started' ? <Redirect from='/getting-started' to={singleColumn ? '/home' : '/deck/getting-started'} exact /> : null}
@@ -8,12 +8,13 @@ import StackTrace from 'stacktrace-js';
import Bundle from '../components/bundle';
import BundleColumnError from '../components/bundle_column_error';
import { ColumnLoading } from '../components/column_loading';
import { forceSingleColumn, hasMultiColumnPath } from '@/flavours/glitch/initial_state';
// Small wrapper to pass multiColumn to the route components
export const WrappedSwitch = ({ multiColumn, children }) => {
const location = useLocation();
const decklessLocation = multiColumn && location.pathname.startsWith('/deck')
const decklessLocation = !forceSingleColumn && hasMultiColumnPath && location.pathname.startsWith('/deck')
? {...location, pathname: location.pathname.slice(5)}
: location;