From d2e8387e2f9c9b6aa95cd955266ad4abe90c080a Mon Sep 17 00:00:00 2001 From: Muniz Date: Sat, 28 Oct 2023 19:34:39 -0300 Subject: [PATCH 1/6] feat: changelog join link --- src/components/participants/ParticipantsModal.tsx | 5 ++--- src/hooks/useRedirectionRule.ts | 9 +++++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/components/participants/ParticipantsModal.tsx b/src/components/participants/ParticipantsModal.tsx index 8d30145..6ca88ee 100644 --- a/src/components/participants/ParticipantsModal.tsx +++ b/src/components/participants/ParticipantsModal.tsx @@ -18,7 +18,7 @@ import { selectPendingUsers, } from "../../state/call"; import DialogModal from "../basic/DialogModal"; -import { selectCallHostId, selectCallUid } from "../../state/call"; +import { selectCallHostId } from "../../state/call"; import { selectUserUid } from "../../state/user"; export interface ParticipantsModalProps { @@ -103,8 +103,7 @@ export default function ParticipantsModal({ } function CallLink() { - const callUid = useAppSelector(selectCallUid); - const link = `${window.location.origin}/join?callUid=${callUid}`; + const link = window.location.href; const handleCopyClick = async () => { await navigator.clipboard.writeText(link); diff --git a/src/hooks/useRedirectionRule.ts b/src/hooks/useRedirectionRule.ts index 041e433..8626355 100644 --- a/src/hooks/useRedirectionRule.ts +++ b/src/hooks/useRedirectionRule.ts @@ -93,11 +93,20 @@ export function getRedirectionRule( } if (path.startsWith("/p2p-call")) { + const callUuid = path.replace("/p2p-call/", ""); + if (hasAuth && !ongoingCall && callUuid) { + return `/join?callUid=${callUuid}`; + } + if (hasAuth && !ongoingCall) { return "/create"; // return "/left"; } + if (!hasAuth && callUuid) { + return `/join?callUid=${callUuid}`; + } + if (!hasAuth) { return "/"; } From caa71e2b55d9d8894f153ab0408f25678145b52f Mon Sep 17 00:00:00 2001 From: Muniz Date: Sat, 28 Oct 2023 20:11:18 -0300 Subject: [PATCH 2/6] refactor: join call link --- src/components/participants/ParticipantsModal.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/participants/ParticipantsModal.tsx b/src/components/participants/ParticipantsModal.tsx index 6ca88ee..93a8661 100644 --- a/src/components/participants/ParticipantsModal.tsx +++ b/src/components/participants/ParticipantsModal.tsx @@ -103,7 +103,7 @@ export default function ParticipantsModal({ } function CallLink() { - const link = window.location.href; + const link = `${window.location.origin}${window.location.pathname}`; const handleCopyClick = async () => { await navigator.clipboard.writeText(link); From ab83eea9e893ae03aa08a2e5d0fff9dbdbbac08b Mon Sep 17 00:00:00 2001 From: Muniz Date: Sat, 28 Oct 2023 20:11:40 -0300 Subject: [PATCH 3/6] fix: redirect to /create after left the call --- src/hooks/useRedirectionRule.ts | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/hooks/useRedirectionRule.ts b/src/hooks/useRedirectionRule.ts index 8626355..260aef8 100644 --- a/src/hooks/useRedirectionRule.ts +++ b/src/hooks/useRedirectionRule.ts @@ -94,9 +94,6 @@ export function getRedirectionRule( if (path.startsWith("/p2p-call")) { const callUuid = path.replace("/p2p-call/", ""); - if (hasAuth && !ongoingCall && callUuid) { - return `/join?callUid=${callUuid}`; - } if (hasAuth && !ongoingCall) { return "/create"; From 5ba2817b264f76832343bfa1b2899b1ae78986a0 Mon Sep 17 00:00:00 2001 From: Muniz Date: Sat, 28 Oct 2023 20:24:58 -0300 Subject: [PATCH 4/6] fix: participants modal tests --- src/components/participants/ParticipantsModal.test.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/participants/ParticipantsModal.test.tsx b/src/components/participants/ParticipantsModal.test.tsx index 6c9a9a1..6bbee33 100644 --- a/src/components/participants/ParticipantsModal.test.tsx +++ b/src/components/participants/ParticipantsModal.test.tsx @@ -38,7 +38,7 @@ describe("ParticipantsModal", () => { preloadedState: { call }, }); expect( - screen.getByText(window.location.href + "join?callUid=" + call.uid) + screen.getByText(`${window.location.origin}${window.location.pathname}`) ).toBeVisible(); }); @@ -51,7 +51,7 @@ describe("ParticipantsModal", () => { await act(() => fireEvent.click(copyButton)); expect(navigator.clipboard.writeText).toHaveBeenCalledWith( - window.location.href + "join?callUid=" + call.uid + `${window.location.origin}${window.location.pathname}` ); const successSnackbar = await waitFor(() => screen.getByRole("alert")); From a78fc5cb12b45b6d5f44b82ba49ecd36dabb246c Mon Sep 17 00:00:00 2001 From: Muniz Date: Sat, 28 Oct 2023 21:03:25 -0300 Subject: [PATCH 5/6] fix: useRedirectionRule hook tests --- src/hooks/useRedirectionRule.test.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/hooks/useRedirectionRule.test.ts b/src/hooks/useRedirectionRule.test.ts index 27a56db..47d512a 100644 --- a/src/hooks/useRedirectionRule.test.ts +++ b/src/hooks/useRedirectionRule.test.ts @@ -130,12 +130,20 @@ describe("getRedirectionRule: /p2p-call", () => { expect(result).toBe("/create"); }); - it("when not authenticated, be forced to reset flow", () => { + it("when not authenticated and the url has call uuid, then go to join page", () => { // TODO: retrieve attempt call uid and convert into "/?joining=" flow const result = getRedirectionRule( { path: "/p2p-call/123-321", hasAuth: false }, {} ); + expect(result).toBe("/join?callUid=123-321"); + }); + + it("when not authenticated and the url has not call uuid, be forced to reset flow", () => { + const result = getRedirectionRule( + { path: "/p2p-call/", hasAuth: false }, + {} + ); expect(result).toBe("/"); }); }); From 003971b55b02d4c2c2847f6d2950aa5a4d181fe8 Mon Sep 17 00:00:00 2001 From: mazuh Date: Sun, 29 Oct 2023 14:30:29 -0300 Subject: [PATCH 6/6] optional isSessionBlocked --- src/hooks/useRedirectionRule.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hooks/useRedirectionRule.ts b/src/hooks/useRedirectionRule.ts index 84348a5..76e8785 100644 --- a/src/hooks/useRedirectionRule.ts +++ b/src/hooks/useRedirectionRule.ts @@ -35,7 +35,7 @@ export default function useRedirectionRule(): string { export interface RedirectionContext { path: string; hasAuth: boolean; - isSessionBlocked: boolean; + isSessionBlocked?: boolean; pendingCall?: string; ongoingCall?: string; }