[Glitch] Change links in multi-column mode so tabs are open in single-column mode
Port 5fad7bd58a
to glitch-soc
Signed-off-by: Claire <claire.github-309c@sitedethib.com>
This commit is contained in:
committed by
Claire
parent
0d61985713
commit
9bd012b7cb
23
app/javascript/flavours/glitch/components/router.tsx
Normal file
23
app/javascript/flavours/glitch/components/router.tsx
Normal file
@ -0,0 +1,23 @@
|
||||
import type { PropsWithChildren } from 'react';
|
||||
import React from 'react';
|
||||
|
||||
import type { History } from 'history';
|
||||
import { createBrowserHistory } from 'history';
|
||||
import { Router as OriginalRouter } from 'react-router';
|
||||
|
||||
import { layoutFromWindow } from 'flavours/glitch/is_mobile';
|
||||
|
||||
const browserHistory = createBrowserHistory();
|
||||
const originalPush = browserHistory.push.bind(browserHistory);
|
||||
|
||||
browserHistory.push = (path: string, state: History.LocationState) => {
|
||||
if (layoutFromWindow() === 'multi-column' && !path.startsWith('/deck')) {
|
||||
originalPush(`/deck${path}`, state);
|
||||
} else {
|
||||
originalPush(path, state);
|
||||
}
|
||||
};
|
||||
|
||||
export const Router: React.FC<PropsWithChildren> = ({ children }) => {
|
||||
return <OriginalRouter history={browserHistory}>{children}</OriginalRouter>;
|
||||
};
|
Reference in New Issue
Block a user