Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,5 @@ devAssets
*.tfbackend
!*.tfbackend.example
crash.log

.worktrees
69 changes: 52 additions & 17 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@
"file-saver": "^2.0.5",
"focus-trap-react": "^10.3.1",
"folds": "^2.6.1",
"framer-motion": "12.34.3",
"html-dom-parser": "^5.1.8",
"html-react-parser": "^4.2.10",
"i18next": "^25.8.13",
Expand All @@ -66,6 +65,7 @@
"matrix-js-sdk": "^38.4.0",
"matrix-widget-api": "1.13.0",
"millify": "^6.1.0",
"motion": "12.35.1",
"pdfjs-dist": "^5.4.624",
"prismjs": "^1.30.0",
"react": "^18.3.1",
Expand Down Expand Up @@ -121,4 +121,4 @@
"vite-plugin-top-level-await": "^1.6.0",
"wrangler": "^4.70.0"
}
}
}
109 changes: 3 additions & 106 deletions src/app/components/BackRouteHandler.tsx
Original file line number Diff line number Diff line change
@@ -1,113 +1,10 @@
import { ReactNode, useCallback } from 'react';
import { useSetAtom } from 'jotai';
import { matchPath, useLocation, useNavigate } from 'react-router-dom';
import {
getDirectPath,
getExplorePath,
getHomePath,
getInboxPath,
getSpacePath,
} from '$pages/pathUtils';
import {
DIRECT_PATH,
EXPLORE_PATH,
HOME_PATH,
INBOX_PATH,
SPACE_PATH,
HOME_ROOM_PATH,
DIRECT_ROOM_PATH,
SPACE_ROOM_PATH,
} from '$pages/paths';
import { lastVisitedRoomIdAtom } from '$state/room/lastRoom';
import { ReactNode } from 'react';
import { useBackRoute } from '$hooks/useBackRoute';

type BackRouteHandlerProps = {
children: (onBack: () => void) => ReactNode;
};
export function BackRouteHandler({ children }: BackRouteHandlerProps) {
const navigate = useNavigate();
const location = useLocation();
const setLastRoomId = useSetAtom(lastVisitedRoomIdAtom);

const goBack = useCallback(() => {
const roomPaths = [HOME_ROOM_PATH, DIRECT_ROOM_PATH, SPACE_ROOM_PATH];

const roomMatch = roomPaths
.map((path) => matchPath({ path, end: false }, location.pathname))
.find((match) => match !== null);

const currentRoomIdOrAlias = roomMatch?.params.roomIdOrAlias;
if (currentRoomIdOrAlias) {
setLastRoomId(decodeURIComponent(currentRoomIdOrAlias));
}

if (
matchPath(
{
path: HOME_PATH,
caseSensitive: true,
end: false,
},
location.pathname
)
) {
navigate(getHomePath());
return;
}
if (
matchPath(
{
path: DIRECT_PATH,
caseSensitive: true,
end: false,
},
location.pathname
)
) {
navigate(getDirectPath());
return;
}
const spaceMatch = matchPath(
{
path: SPACE_PATH,
caseSensitive: true,
end: false,
},
location.pathname
);
const encodedSpaceIdOrAlias = spaceMatch?.params.spaceIdOrAlias;
const decodedSpaceIdOrAlias =
encodedSpaceIdOrAlias && decodeURIComponent(encodedSpaceIdOrAlias);

if (decodedSpaceIdOrAlias) {
navigate(getSpacePath(decodedSpaceIdOrAlias));
return;
}
if (
matchPath(
{
path: EXPLORE_PATH,
caseSensitive: true,
end: false,
},
location.pathname
)
) {
navigate(getExplorePath());
return;
}
if (
matchPath(
{
path: INBOX_PATH,
caseSensitive: true,
end: false,
},
location.pathname
)
) {
navigate(getInboxPath());
}
}, [navigate, location, setLastRoomId]);

const goBack = useBackRoute();
return children(goBack);
}
1 change: 1 addition & 0 deletions src/app/components/CallEmbedProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ export function CallEmbedProvider({ children }: CallEmbedProviderProps) {
left: 0,
width: '100%',
height: '50%',
zIndex: 11,
}}
ref={callEmbedRef}
/>
Expand Down
Loading
Loading