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

refactor: calls table and corresponding tables have been dropped; call is replaced with session_id. #245

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
- `apps/dashboard` - LiteSpace admin dashboard.
- `apps/mobile` - LiteSpace mobile app.
- `apps/nebula` - LiteSpace landing page.
- `apps/nova` - LiteSpace main web platform.
- `apps/nova` - LiteSpace main web platform.

# Project Setup

Expand Down
2 changes: 1 addition & 1 deletion apps/nova/src/components/Call/GhostView.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useFormatMessage } from "@litespace/luna/hooks/intl";
import { Typography } from "@litespace/luna/Typography";
import { RemoteStream } from "@litespace/headless/calls";
import { RemoteStream } from "@litespace/headless/sessions";
import { isEmpty } from "lodash";
import React from "react";
import UserMedia from "@/components/Call/UserMedia";
Expand Down
2 changes: 1 addition & 1 deletion apps/nova/src/components/Interviews/Interview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ const Interview: React.FC<{

<div className="flex flex-row gap-2 mt-4">
{upcoming ? (
<Link to={Route.Call.replace(":id", interview.ids.call.toString())}>
<Link to={Route.Call.replace(":id", interview.ids.session)}>
<Button size={sm ? ButtonSize.Small : ButtonSize.Tiny}>
{!started
? intl.formatMessage(
Expand Down
2 changes: 1 addition & 1 deletion apps/nova/src/components/Lessons/Lesson.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ const Lesson: React.FC<

<div className="flex flex-row gap-2 mt-4">
{upcoming ? (
<Link to={Route.Call.replace(":id", lesson.callId.toString())}>
<Link to={Route.Call.replace(":id", lesson.sessionId)}>
<Button size={sm ? ButtonSize.Small : ButtonSize.Tiny}>
{inprogress
? intl("page.lessons.lesson.join.inprogress", {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,16 @@ import {
Button,
ButtonType,
ButtonSize,
ButtonVariant,
} from "@litespace/luna/Button";
import { asFullAssetUrl } from "@litespace/luna/backend";
import { useFormatMessage } from "@litespace/luna/hooks/intl";
import { ICall } from "@litespace/types";
import { ISession } from "@litespace/types";
import React from "react";
import { Link } from "react-router-dom";
import { Route } from "@/types/routes";

const PendingInterview: React.FC<{
interviewer: ICall.PopuldatedMember;
call: ICall.Self;
}> = ({ interviewer, call }) => {
interviewer: ISession.PopuldatedMember;
session: ISession.Self;
}> = ({ interviewer }) => {
const intl = useFormatMessage();
return (
<div>
Expand Down Expand Up @@ -57,7 +54,8 @@ const PendingInterview: React.FC<{
</p>

<div className="flex flex-row gap-4 mt-6">
<Link to={Route.Call.replace(":id", call.id.toString())}>
{/*
<Link to={Route.Call.replace(":id", session.sessionId)}>
<Button
size={ButtonSize.Small}
type={ButtonType.Main}
Expand All @@ -66,6 +64,7 @@ const PendingInterview: React.FC<{
{intl("global.labels.go")}
</Button>
</Link>
*/}
<Button size={ButtonSize.Small} type={ButtonType.Error}>
{intl("global.labels.cancel")}
</Button>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { destructureInterviewStatus } from "@litespace/sol/interview";
import { ICall, IInterview } from "@litespace/types";
import { ISession, IInterview } from "@litespace/types";
import React, { useMemo } from "react";
import PendingInterview from "@/components/TutorOnboardingSteps/Interview/ScheduledInterview/PendingInterview";
import PassedInterview from "@/components/TutorOnboardingSteps/Interview/ScheduledInterview/PassedInterview";

const ScheduledInterview: React.FC<{
interview: IInterview.Self;
call: ICall.Self;
members: ICall.PopuldatedMember[];
}> = ({ interview, call, members }) => {
session: ISession.Self;
members: ISession.PopuldatedMember[];
}> = ({ interview, session, members }) => {
// todo: handle canceled and rejected
const { pending, passed, rejected, canceled } = useMemo(
() => destructureInterviewStatus(interview.status),
Expand All @@ -25,7 +25,7 @@ const ScheduledInterview: React.FC<{
return (
<div>
{pending && interviewer ? (
<PendingInterview interviewer={interviewer} call={call} />
<PendingInterview interviewer={interviewer} session={session} />
) : passed && interviewer ? (
<PassedInterview
feedback={interview.feedback.interviewer}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import RawHtml from "@/components/TutorOnboardingSteps/RawHtml";
// import ScheduledInterview from "@/components/TutorOnboardingSteps/Interview/ScheduledInterview";

const Interview: React.FC<{
interviews: IInterview.FindPagedInterviewsProps;
current: Element<IInterview.FindInterviewsApiResponse["list"]> | null;
}> = ({ current }) => {
// const onScheduleSuccess = useCallback(() => {
Expand Down
5 changes: 2 additions & 3 deletions apps/nova/src/components/TutorOnboardingSteps/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@ import { Element, IInterview } from "@litespace/types";

const TutorOnboardingSteps: React.FC<{
step: number;
interviews: IInterview.FindPagedInterviewsProps;
current: Element<IInterview.FindInterviewsApiResponse["list"]> | null;
}> = ({ step, interviews, current }) => {
}> = ({ step, current }) => {
if (step === TutorOnboardingStep.Interview)
return <Interview interviews={interviews} current={current} />;
return <Interview current={current} />;
if (step === TutorOnboardingStep.Media) return <MediaShot />;
if (step === TutorOnboardingStep.Profile) return "todo";
return null;
Expand Down
16 changes: 8 additions & 8 deletions apps/nova/src/hooks/call.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { useCallback, useEffect, useState, useRef } from "react";
import { isPermissionDenied, safe } from "@/lib/error";
import { MediaConnection } from "peerjs";
import peer from "@/lib/peer";
import { Wss } from "@litespace/types";
import { ISession, Wss } from "@litespace/types";
import hark from "hark";
import { useToast } from "@litespace/luna/Toast";
import { useFormatMessage } from "@litespace/luna/hooks/intl";
Expand Down Expand Up @@ -235,7 +235,7 @@ function useStreamState(stream: MediaStream | null) {

export function useCallEvents(
stream: MediaStream | null,
call: number | null,
session: ISession.Id | null,
mate?: number
) {
const [mateVideo, setMateVideo] = useState<boolean>(false);
Expand All @@ -245,18 +245,18 @@ export function useCallEvents(

const notifyCameraToggle = useCallback(
(camera: boolean) => {
if (!call || !socket) return;
socket.emit(Wss.ClientEvent.ToggleCamera, { call, camera });
if (!session || !socket) return;
socket.emit(Wss.ClientEvent.ToggleCamera, { session, camera });
},
[call, socket]
[session, socket]
);

const notifyMicToggle = useCallback(
(mic: boolean) => {
if (!call || !socket) return;
socket.emit(Wss.ClientEvent.ToggleMic, { call, mic });
if (!session || !socket) return;
socket.emit(Wss.ClientEvent.ToggleMic, { session, mic });
},
[call, socket]
[session, socket]
);

const onCameraToggle = useCallback(
Expand Down
59 changes: 20 additions & 39 deletions apps/nova/src/pages/Call.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,18 @@ import {
// import { useMediaQueries } from "@litespace/luna/hooks/media";
// import { useRender } from "@litespace/luna/hooks/common";
// import { useFormatMessage } from "@litespace/luna/hooks/intl";
import { useParams } from "react-router-dom";
import cn from "classnames";
// import { useFullScreen } from "@/hooks/call";
// import Media from "@/components/Call/Media";
// import Messages from "@/components/Chat/Messages";
import { orNull, orUndefined } from "@litespace/sol/utils";
import {
useCallMembers,
// useCall,
useCallV2,
useFindCallRoomById,
//useSessionMembers,
//usePeerIds,
useSessionV2,
//useFindSessionRoomById,
useFullScreen,
usePeerIds,
} from "@litespace/headless/calls";
} from "@litespace/headless/sessions";
import { useDisplayRecorder } from "@litespace/headless/recorder";
import { isGhost } from "@/lib/ghost";
import CallView, { CallViewProps } from "@/components/Call/CallView";
Expand All @@ -32,7 +30,6 @@ import Video from "@litespace/assets/Video";
import Microphone from "@litespace/assets/Microphone";
import VideoSlash from "@litespace/assets/VideoSlash";
import MicrophoneSlash from "@litespace/assets/MicrophoneSlash";
import { ICall } from "@litespace/types";
import { useUser } from "@litespace/headless/context/user";
// import GhostView from "@/components/Call/GhostView";

Expand All @@ -41,29 +38,10 @@ const Call: React.FC = () => {
// const chat = useRender();
// const intl = useFormatMessage();
// const mediaQueries = useMediaQueries();
const { id, type } = useParams<{ id: string; type: ICall.Type }>();
// const { isFullScreen, toggleFullScreen, ref } = useFullScreen();

const callId = useMemo(() => {
const call = Number(id);
if (!id || Number.isNaN(call)) return null;
return call;
}, [id]);

const ctype = useMemo(() => {
if (type != "lesson" && type != "interview") return null;
return type;
}, [type]);

const callRoom = useFindCallRoomById(!isGhost ? callId : null);

const mateInfo = useMemo(() => {
if (!callRoom.data) return;
return callRoom.data.members.find((member) => member.id !== user?.id);
}, [callRoom.data, user?.id]);

const members = useCallMembers(callId, ctype);
useEffect(() => console.log("In App members: ", members), [members]);
//const members = useSessionMembers(sessionId);
//useEffect(() => console.log("In App members: ", members), [members]);

// const messages = useMemo(
// () =>
Expand Down Expand Up @@ -124,20 +102,22 @@ const Call: React.FC = () => {

const fullScreen = useFullScreen<HTMLDivElement>();

/*
const peers = usePeerIds(
useMemo(
() => ({
callId,
sessionId,
isGhost,
mateUserId: orNull(mateInfo?.id),
role: orNull(user?.role),
disableGhost: false,
}),
[callId, mateInfo?.id, user?.role]
[sessionId, mateInfo?.id, user?.role]
)
);
*/

const onCloseCall = useCallback(() => {
const onCloseSession = useCallback(() => {
// peers.ghost.refetch();
// peers.tutor.refetch();
}, []);
Expand All @@ -152,16 +132,16 @@ const Call: React.FC = () => {
});
*/

const { userMedia, mateStream, mateScreenStream, ghostStreams } = useCallV2(
const { userMedia, mateStream, mateScreenStream, ghostStreams } = useSessionV2(
useMemo(
() => ({
isGhost,
ghostPeerId: orNull(peers.ghost.data),
tutorPeerId: orNull(peers.tutor.data),
ghostPeerId: orNull("ghost"), // TODO: pass peers.ghost.data
tutorPeerId: orNull("ghost"), // TODO: pass peers.tutor.data
userId: orNull(user?.id),
onCloseCall,
onCloseSession,
}),
[onCloseCall, peers.ghost.data, peers.tutor.data, user?.id]
[onCloseSession, user?.id]
)
);

Expand All @@ -183,7 +163,7 @@ const Call: React.FC = () => {
screen: mateScreenStream,
},
speaking: true,
name: orUndefined(mateInfo?.name),
name: undefined // orUndefined(mateInfo?.name),
},
fullScreen: {
enabled: fullScreen.enabled,
Expand All @@ -195,7 +175,6 @@ const Call: React.FC = () => {
fullScreen.enabled,
fullScreen.exit,
fullScreen.start,
mateInfo?.name,
mateScreenStream,
mateStream,
user?.name,
Expand Down Expand Up @@ -308,12 +287,14 @@ const Call: React.FC = () => {
/*
* TODO: replace this by members views
*/
/*
<div>
<h1>Joined members</h1>
{members.map((m) => (
<label className="mx-1">-{m}-</label>
))}
</div>
*/
}

{/* <Button
Expand Down
6 changes: 0 additions & 6 deletions packages/atlas/src/atlas.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { User } from "@/user";
import { Auth } from "@/auth";
import { Backend } from "@litespace/types";
import { Call } from "@/call";
import { Plan } from "@/plan";
import { Coupon } from "@/coupon";
import { Invite } from "@/invite";
Expand All @@ -18,12 +17,10 @@ import { Invoice } from "@/invoice";
import { Topic } from "@/topic";
import { AuthToken } from "@/client";
import { Cache } from "@/cache";
import { Peer } from "@/peer";

export class Atlas {
public readonly user: User;
public readonly auth: Auth;
public readonly call: Call;
public readonly plan: Plan;
public readonly coupon: Coupon;
public readonly invite: Invite;
Expand All @@ -39,12 +36,10 @@ export class Atlas {
public readonly invoice: Invoice;
public readonly cache: Cache;
public readonly topic: Topic;
public readonly peer: Peer;

constructor(backend: Backend, token: AuthToken | null) {
this.user = new User(backend, token);
this.auth = new Auth(backend, token);
this.call = new Call(backend, token);
this.plan = new Plan(backend, token);
this.coupon = new Coupon(backend, token);
this.invite = new Invite(backend, token);
Expand All @@ -60,6 +55,5 @@ export class Atlas {
this.invoice = new Invoice(backend, token);
this.cache = new Cache(backend, token);
this.topic = new Topic(backend, token);
this.peer = new Peer(backend, token);
}
}
19 changes: 0 additions & 19 deletions packages/atlas/src/call.ts

This file was deleted.

4 changes: 0 additions & 4 deletions packages/atlas/src/chat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,6 @@ export class Chat extends Base {
return await this.get({ route: `/api/v1/chat/room/members/${room}` });
}

async findCallRoom(call: number): Promise<IRoom.FindCallRoomApiResponse> {
return await this.get({ route: `/api/v1/chat/room/call/${call}` });
}

async updateRoom(
room: number,
payload: IRoom.UpdateRoomApiPayload
Expand Down
Loading
Loading