From 5233ab609a529fc183cf4beffc550a1beadebb4d Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 8 Jan 2025 12:26:43 +0000 Subject: [PATCH 1/2] Update dependency react-router-dom to v7 --- package.json | 2 +- yarn.lock | 49 +++++++++++++++++++++++++++++++++---------------- 2 files changed, 34 insertions(+), 17 deletions(-) diff --git a/package.json b/package.json index 54323c253..4c21136ad 100644 --- a/package.json +++ b/package.json @@ -102,7 +102,7 @@ "react": "18", "react-dom": "18", "react-i18next": "^15.0.0", - "react-router-dom": "^6.28.0", + "react-router-dom": "^7.0.0", "react-use-clipboard": "^1.0.7", "react-use-measure": "^2.1.1", "rxjs": "^7.8.1", diff --git a/yarn.lock b/yarn.lock index c23f34136..e85a55661 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2563,11 +2563,6 @@ "@react-spring/shared" "~9.7.5" "@react-spring/types" "~9.7.5" -"@remix-run/router@1.21.0": - version "1.21.0" - resolved "https://registry.yarnpkg.com/@remix-run/router/-/router-1.21.0.tgz#c65ae4262bdcfe415dbd4f64ec87676e4a56e2b5" - integrity sha512-xfSkCAchbdG5PnbrKqFWwia4Bi61nH+wm8wLEqfHDyp7Y3dZzgqS2itV8i4gAq9pC2HsTpwyBC6Ds8VHZ96JlA== - "@rollup/pluginutils@^5.1.0", "@rollup/pluginutils@^5.1.3": version "5.1.3" resolved "https://registry.yarnpkg.com/@rollup/pluginutils/-/pluginutils-5.1.3.tgz#3001bf1a03f3ad24457591f2c259c8e514e0dbdf" @@ -3077,6 +3072,11 @@ resolved "https://registry.yarnpkg.com/@types/content-type/-/content-type-1.1.8.tgz#319644d07ee6b4bfc734483008393b89b99f0219" integrity sha512-1tBhmVUeso3+ahfyaKluXe38p+94lovUZdoVfQ3OnJo9uJC42JT7CBoN3k9HYhAae+GwiBYmHu+N9FZhOG+2Pg== +"@types/cookie@^0.6.0": + version "0.6.0" + resolved "https://registry.yarnpkg.com/@types/cookie/-/cookie-0.6.0.tgz#eac397f28bf1d6ae0ae081363eca2f425bedf0d5" + integrity sha512-4Kh9a6B2bQciAhf7FSuMRRkUWecJgJu9nPnx3yzpsfXX/c50REIqpHY4C82bXP90qrLtXtkDxTZosYO3UpOwlA== + "@types/estree@1.0.6", "@types/estree@^1.0.0": version "1.0.6" resolved "https://registry.yarnpkg.com/@types/estree/-/estree-1.0.6.tgz#628effeeae2064a1b4e79f78e81d87b7e5fc7b50" @@ -4240,6 +4240,11 @@ convert-source-map@^2.0.0: resolved "https://registry.yarnpkg.com/convert-source-map/-/convert-source-map-2.0.0.tgz#4b560f649fc4e918dd0ab75cf4961e8bc882d82a" integrity sha512-Kvp459HrV2FEJ1CAsi1Ku+MY3kasH19TFykTz2xWmMeq6bk2NU3XXvfJ+Q61m0xktWwt+1HSYf3JZsTms3aRJg== +cookie@^1.0.1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/cookie/-/cookie-1.0.2.tgz#27360701532116bd3f1f9416929d176afe1e4610" + integrity sha512-9Kr/j4O16ISv8zBBhJoi4bXOYNTkFLOqSL3UDB0njXxCXNezjeyVrJyGOWtgfs/q2km1gwBcfH8q1yEGoMYunA== + copy-to-clipboard@^3.3.1: version "3.3.3" resolved "https://registry.yarnpkg.com/copy-to-clipboard/-/copy-to-clipboard-3.3.3.tgz#55ac43a1db8ae639a4bd99511c148cdd1b83a1b0" @@ -7347,20 +7352,22 @@ react-remove-scroll@^2.6.1: use-callback-ref "^1.3.3" use-sidecar "^1.1.2" -react-router-dom@^6.28.0: - version "6.28.1" - resolved "https://registry.yarnpkg.com/react-router-dom/-/react-router-dom-6.28.1.tgz#b78fe452d2cd31919b80e57047a896bfa1509f8c" - integrity sha512-YraE27C/RdjcZwl5UCqF/ffXnZDxpJdk9Q6jw38SZHjXs7NNdpViq2l2c7fO7+4uWaEfcwfGCv3RSg4e1By/fQ== +react-router-dom@^7.0.0: + version "7.1.1" + resolved "https://registry.yarnpkg.com/react-router-dom/-/react-router-dom-7.1.1.tgz#9e76fb63a762ba5da13032f5fd9e4a24946396b6" + integrity sha512-vSrQHWlJ5DCfyrhgo0k6zViOe9ToK8uT5XGSmnuC2R3/g261IdIMpZVqfjD6vWSXdnf5Czs4VA/V60oVR6/jnA== dependencies: - "@remix-run/router" "1.21.0" - react-router "6.28.1" + react-router "7.1.1" -react-router@6.28.1: - version "6.28.1" - resolved "https://registry.yarnpkg.com/react-router/-/react-router-6.28.1.tgz#f82317ab24eee67d7beb7b304c0378b2b48fa178" - integrity sha512-2omQTA3rkMljmrvvo6WtewGdVh45SpL9hGiCI9uUrwGGfNFDIvGK4gYJsKlJoNVi6AQZcopSCballL+QGOm7fA== +react-router@7.1.1: + version "7.1.1" + resolved "https://registry.yarnpkg.com/react-router/-/react-router-7.1.1.tgz#88f5657fa5b8f0b918c7222ec710de0274d00b2e" + integrity sha512-39sXJkftkKWRZ2oJtHhCxmoCrBCULr/HAH4IT5DHlgu/Q0FCPV0S4Lx+abjDTx/74xoZzNYDYbOZWlJjruyuDQ== dependencies: - "@remix-run/router" "1.21.0" + "@types/cookie" "^0.6.0" + cookie "^1.0.1" + set-cookie-parser "^2.6.0" + turbo-stream "2.4.0" react-style-singleton@^2.2.1, react-style-singleton@^2.2.2: version "2.2.3" @@ -7824,6 +7831,11 @@ set-blocking@^2.0.0: resolved "https://registry.yarnpkg.com/set-blocking/-/set-blocking-2.0.0.tgz#045f9782d011ae9a6803ddd382b24392b3d890f7" integrity sha512-KiKBS8AnWGEyLzofFfmvKwpdPzqiy16LvQfK3yv/fVH7Bj13/wl3JSR1J+rfgRE9q7xUJK4qvgS8raSOeLUehw== +set-cookie-parser@^2.6.0: + version "2.7.1" + resolved "https://registry.yarnpkg.com/set-cookie-parser/-/set-cookie-parser-2.7.1.tgz#3016f150072202dfbe90fadee053573cc89d2943" + integrity sha512-IOc8uWeOZgnb3ptbCURJWNjWUPcO3ZnTTdzsurqERrP6nPyv+paC55vJM0LpOlT2ne+Ix+9+CRG1MNLlyZ4GjQ== + set-function-length@^1.2.2: version "1.2.2" resolved "https://registry.yarnpkg.com/set-function-length/-/set-function-length-1.2.2.tgz#aac72314198eaed975cf77b2c3b6b880695e5449" @@ -8385,6 +8397,11 @@ tunnel@^0.0.6: resolved "https://registry.yarnpkg.com/tunnel/-/tunnel-0.0.6.tgz#72f1314b34a5b192db012324df2cc587ca47f92c" integrity sha512-1h/Lnq9yajKY2PEbBadPXj3VxsDDu844OnaAo52UVmIzIvwwtBPIuNvkjuzBlTWpfJyUbG3ez0KSBibQkj4ojg== +turbo-stream@2.4.0: + version "2.4.0" + resolved "https://registry.yarnpkg.com/turbo-stream/-/turbo-stream-2.4.0.tgz#1e4fca6725e90fa14ac4adb782f2d3759a5695f0" + integrity sha512-FHncC10WpBd2eOmGwpmQsWLDoK4cqsA/UT/GqNoaKOQnT8uzhtCbg3EoUDMvqpOSAI0S26mr0rkjzbOO6S3v1g== + type-check@^0.4.0, type-check@~0.4.0: version "0.4.0" resolved "https://registry.yarnpkg.com/type-check/-/type-check-0.4.0.tgz#07b8203bfa7056c0657050e3ccd2c37730bab8f1" From 882a74d115c4620dd579b680c71e7064fd8e17c3 Mon Sep 17 00:00:00 2001 From: Hugh Nimmo-Smith Date: Wed, 8 Jan 2025 16:39:14 +0000 Subject: [PATCH 2/2] Handle promises --- src/ClientContext.tsx | 2 +- src/UserMenuContainer.tsx | 5 ++++- src/auth/LoginPage.tsx | 6 +++--- src/auth/RegisterPage.tsx | 10 ++++++---- src/home/RegisteredView.tsx | 6 ++++-- src/home/UnauthenticatedView.tsx | 6 ++++-- src/room/CallEndedView.tsx | 5 ++++- src/room/GroupCallView.tsx | 4 ++-- src/room/LobbyView.tsx | 6 +++++- 9 files changed, 33 insertions(+), 17 deletions(-) diff --git a/src/ClientContext.tsx b/src/ClientContext.tsx index e6eed7ab5..791005bb6 100644 --- a/src/ClientContext.tsx +++ b/src/ClientContext.tsx @@ -228,7 +228,7 @@ export const ClientProvider: FC = ({ children }) => { await client.clearStores(); clearSession(); setInitClientState(null); - navigate("/"); + await navigate("/"); PosthogAnalytics.instance.setRegistrationType(RegistrationType.Guest); }, [navigate, initClientState?.client]); diff --git a/src/UserMenuContainer.tsx b/src/UserMenuContainer.tsx index e1cc68a25..fc3242103 100644 --- a/src/UserMenuContainer.tsx +++ b/src/UserMenuContainer.tsx @@ -7,6 +7,7 @@ Please see LICENSE in the repository root for full details. import { type FC, useCallback, useState } from "react"; import { useNavigate, useLocation } from "react-router-dom"; +import { logger } from "matrix-js-sdk/src/logger"; import { useClientLegacy } from "./ClientContext"; import { useProfile } from "./profile/useProfile"; @@ -45,7 +46,9 @@ export const UserMenuContainer: FC = ({ preventNavigation = false }) => { logout?.(); break; case "login": - navigate("/login", { state: { from: location } }); + navigate("/login", { state: { from: location } })?.catch((error) => + logger.error("Failed to navigate to login", error), + ); break; } }, diff --git a/src/auth/LoginPage.tsx b/src/auth/LoginPage.tsx index b7b84530d..66dd6abd3 100644 --- a/src/auth/LoginPage.tsx +++ b/src/auth/LoginPage.tsx @@ -48,7 +48,7 @@ export const LoginPage: FC = () => { } login(homeserver, usernameRef.current.value, passwordRef.current.value) - .then(([client, session]) => { + .then(async ([client, session]) => { if (!setClient) { return; } @@ -61,9 +61,9 @@ export const LoginPage: FC = () => { if (locationState && locationState.from) { // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore - navigate(locationState.from); + await navigate(locationState.from); } else { - navigate("/"); + await navigate("/"); } PosthogAnalytics.instance.eventLogin.track(); }) diff --git a/src/auth/RegisterPage.tsx b/src/auth/RegisterPage.tsx index 988d71fc2..46d04552b 100644 --- a/src/auth/RegisterPage.tsx +++ b/src/auth/RegisterPage.tsx @@ -100,15 +100,15 @@ export const RegisterPage: FC = () => { }; submit() - .then(() => { + .then(async () => { // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore if (location.state?.from) { // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore - navigate(location.state?.from); + await navigate(location.state?.from); } else { - navigate("/"); + await navigate("/"); } }) .catch((error) => { @@ -141,7 +141,9 @@ export const RegisterPage: FC = () => { useEffect(() => { if (!loading && authenticated && !passwordlessUser && !registering) { - navigate("/"); + navigate("/")?.catch((error) => { + logger.error("Failed to navigate to /", error); + }); } }, [loading, navigate, authenticated, passwordlessUser, registering]); diff --git a/src/home/RegisteredView.tsx b/src/home/RegisteredView.tsx index 9101da57c..3d3d864cd 100644 --- a/src/home/RegisteredView.tsx +++ b/src/home/RegisteredView.tsx @@ -77,7 +77,7 @@ export const RegisteredView: FC = ({ client }) => { if (!createRoomResult.password) throw new Error("Failed to create room with shared secret"); - navigate( + await navigate( getRelativeRoomUrl( createRoomResult.roomId, { kind: E2eeType.SHARED_KEY, secret: createRoomResult.password }, @@ -106,7 +106,9 @@ export const RegisteredView: FC = ({ client }) => { const [existingAlias, setExistingAlias] = useState(); const onJoinExistingRoom = useCallback(() => { - navigate(`/${existingAlias}`); + navigate(`/${existingAlias}`)?.catch((error) => { + logger.error("Failed to navigate to existing alias", error); + }); }, [navigate, existingAlias]); return ( diff --git a/src/home/UnauthenticatedView.tsx b/src/home/UnauthenticatedView.tsx index d3cde0f8a..90c37c50a 100644 --- a/src/home/UnauthenticatedView.tsx +++ b/src/home/UnauthenticatedView.tsx @@ -91,7 +91,9 @@ export const UnauthenticatedView: FC = () => { setOnFinished(() => { setClient({ client, session }); const aliasLocalpart = roomAliasLocalpartFromRoomName(roomName); - navigate(`/${aliasLocalpart}`); + navigate(`/${aliasLocalpart}`)?.catch((error) => { + logger.error("Failed to navigate to alias localpart", error); + }); }); setLoading(false); @@ -110,7 +112,7 @@ export const UnauthenticatedView: FC = () => { throw new Error("Failed to create room with shared secret"); setClient({ client, session }); - navigate( + await navigate( getRelativeRoomUrl( createRoomResult.roomId, { kind: E2eeType.SHARED_KEY, secret: createRoomResult.password }, diff --git a/src/room/CallEndedView.tsx b/src/room/CallEndedView.tsx index 77bd10983..99abfa42c 100644 --- a/src/room/CallEndedView.tsx +++ b/src/room/CallEndedView.tsx @@ -16,6 +16,7 @@ import { type MatrixClient } from "matrix-js-sdk/src/client"; import { Trans, useTranslation } from "react-i18next"; import { Button, Heading, Text } from "@vector-im/compound-web"; import { useNavigate } from "react-router-dom"; +import { logger } from "matrix-js-sdk/src/logger"; import styles from "./CallEndedView.module.css"; import feedbackStyle from "../input/FeedbackInput.module.css"; @@ -76,7 +77,9 @@ export const CallEndedView: FC = ({ setSurveySubmitted(true); } else if (!confineToRoom) { // if the user already has an account immediately go back to the home screen - navigate("/"); + navigate("/")?.catch((error) => { + logger.error("Failed to navigate to /", error); + }); } }, 1000); }, 1000); diff --git a/src/room/GroupCallView.tsx b/src/room/GroupCallView.tsx index e7a0e7462..be43524dd 100644 --- a/src/room/GroupCallView.tsx +++ b/src/room/GroupCallView.tsx @@ -257,13 +257,13 @@ export const GroupCallView: FC = ({ sendInstantly && audioPromise ? audioPromise : undefined, ) // Only sends matrix leave event. The Livekit session will disconnect once the ActiveCall-view unmounts. - .then(() => { + .then(async () => { if ( !isPasswordlessUser && !confineToRoom && !PosthogAnalytics.instance.isEnabled() ) { - navigate("/"); + await navigate("/"); } }) .catch((e) => { diff --git a/src/room/LobbyView.tsx b/src/room/LobbyView.tsx index 6062aeedf..ab267c237 100644 --- a/src/room/LobbyView.tsx +++ b/src/room/LobbyView.tsx @@ -87,7 +87,11 @@ export const LobbyView: FC = ({ ); const navigate = useNavigate(); - const onLeaveClick = useCallback(() => navigate("/"), [navigate]); + const onLeaveClick = useCallback(() => { + navigate("/")?.catch((error) => { + logger.error("Failed to navigate to /", error); + }); + }, [navigate]); const recentsButtonInFooter = useMediaQuery("(max-height: 500px)"); const recentsButton = !confineToRoom && (