Skip to content

Commit

Permalink
Merge branch 'main' into release
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronshiel committed Oct 4, 2023
2 parents 67e32af + f372fb8 commit db85082
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 3 deletions.
3 changes: 3 additions & 0 deletions client/src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,7 @@ export async function fetchUsers(
disableThumbnailRecommendation
disableLevelProgressDisplay
completeSubjectsNotificationText
recordTimeLimitSeconds
}
orgPermissions {
orgId
Expand Down Expand Up @@ -1080,6 +1081,7 @@ export async function fetchMentorById(
disableThumbnailRecommendation
disableLevelProgressDisplay
completeSubjectsNotificationText
recordTimeLimitSeconds
}
orgPermissions {
orgId
Expand Down Expand Up @@ -1256,6 +1258,7 @@ export async function fetchMentorConfig(
disableThumbnailRecommendation
disableLevelProgressDisplay
completeSubjectsNotificationText
recordTimeLimitSeconds
}
}
`,
Expand Down
45 changes: 42 additions & 3 deletions client/src/components/record/video-recorder.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ import { UseWithRecordState } from "types";
import PermCameraMicIcon from "@mui/icons-material/PermCameraMic";
import { useWithVideoSegmentation } from "components/record/video-segmentation";
import { useWithImage } from "hooks/graphql/use-with-image";
import { MentorConfig } from "types-gql";
import useActiveMentor from "store/slices/mentor/useActiveMentor";

function VideoRecorder(props: {
classes: Record<string, string>;
Expand Down Expand Up @@ -53,6 +55,10 @@ function VideoRecorder(props: {
: "video/mp4";
const videoSaveMimeType = isVirtualBgMentor ? "video/webm" : "video/mp4";
const videoSaveName = isVirtualBgMentor ? "video.webm" : "video.mp4";
const { getData } = useActiveMentor();
const mentorConfig: MentorConfig | undefined = getData(
(m) => m.data?.mentorConfig
);

//Using refs to access states variables in event handler
const recordStopCountdownRef = useRef(recordStopCountdown);
Expand Down Expand Up @@ -129,12 +135,18 @@ function VideoRecorder(props: {
useEffect(() => {
if (
!recordState.isRecording ||
!recordState?.curAnswer?.minVideoLength ||
(!recordState?.curAnswer?.minVideoLength &&
!mentorConfig?.recordTimeLimitSeconds) ||
autoStoppingIdle
) {
return;
}
if (recordDurationCounter > recordState?.curAnswer?.minVideoLength) {
if (
(recordState?.curAnswer?.minVideoLength &&
recordDurationCounter > recordState.curAnswer.minVideoLength) ||
(mentorConfig &&
recordDurationCounter > mentorConfig.recordTimeLimitSeconds)
) {
setAutoStoppingIdle(true);
beginStopRecordingCountdown();
}
Expand Down Expand Up @@ -289,6 +301,14 @@ function VideoRecorder(props: {
: null
);

function getMinSecondText(minSeconds: number): string {
const minutes = Math.trunc(minSeconds / 60);
const seconds = Math.trunc(minSeconds % 60);
return `${minutes > 0 ? minutes + " min" : ""}${
minutes > 0 && seconds > 0 ? " and " : ""
}${seconds > 0 ? seconds + " sec" : ""}`;
}

function getRecordTimeText(recordTime: number): string {
const minutes = Math.trunc(recordTime / 60);
const seconds = Math.trunc(recordTime % 60);
Expand All @@ -298,7 +318,7 @@ function VideoRecorder(props: {
Number(seconds / 10) < 1
? `0${seconds.toString()}`
: `${seconds.toString()}`;
return `${minutesString}:${secondsString}`;
return `${minutesString}m:${secondsString}s`;
}

const backgroundImageStyling: React.CSSProperties = isVirtualBgMentor
Expand All @@ -321,6 +341,25 @@ function VideoRecorder(props: {
: "visible",
}}
>
{mentorConfig?.recordTimeLimitSeconds ||
recordState.curAnswer?.minVideoLength ? (
<Typography
data-cy="instruction"
style={{
textAlign: "center",
visibility: cameraIsOn ? "inherit" : "hidden",
}}
>
<b>Note:</b> You may record a video up to{" "}
{getMinSecondText(
recordState.curAnswer?.minVideoLength != undefined
? recordState.curAnswer?.minVideoLength
: mentorConfig?.recordTimeLimitSeconds || 0
)}{" "}
long.
</Typography>
) : undefined}

<Typography
data-cy="instruction"
style={{
Expand Down
1 change: 1 addition & 0 deletions client/src/types-gql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ export interface MentorConfig {
disableThumbnailRecommendation: boolean;
disableLevelProgressDisplay: boolean;
completeSubjectsNotificationText: string;
recordTimeLimitSeconds: number;
}

export interface MentorGQL {
Expand Down

0 comments on commit db85082

Please sign in to comment.