Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use call link as join link #49

Merged
merged 7 commits into from
Oct 29, 2023
Merged
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
4 changes: 2 additions & 2 deletions src/components/participants/ParticipantsModal.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});

Expand All @@ -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"));
Expand Down
5 changes: 2 additions & 3 deletions src/components/participants/ParticipantsModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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.origin}${window.location.pathname}`;

const handleCopyClick = async () => {
await navigator.clipboard.writeText(link);
Expand Down
10 changes: 9 additions & 1 deletion src/hooks/useRedirectionRule.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -213,12 +213,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, isSessionBlocked: 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("/");
});

Expand Down
8 changes: 7 additions & 1 deletion src/hooks/useRedirectionRule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export default function useRedirectionRule(): string {
export interface RedirectionContext {
path: string;
hasAuth: boolean;
isSessionBlocked: boolean;
isSessionBlocked?: boolean;
pendingCall?: string;
ongoingCall?: string;
}
Expand Down Expand Up @@ -127,6 +127,8 @@ export function getRedirectionRule(
}

if (path.startsWith("/p2p-call")) {
const callUuid = path.replace("/p2p-call/", "");

if (isSessionBlocked) {
return "/blocked-session";
}
Expand All @@ -136,6 +138,10 @@ export function getRedirectionRule(
// return "/left";
}

if (!hasAuth && callUuid) {
return `/join?callUid=${callUuid}`;
}

if (!hasAuth) {
return "/";
}
Expand Down