Skip to content

Commit

Permalink
Notification Settings
Browse files Browse the repository at this point in the history
  • Loading branch information
ryantanen committed Oct 13, 2024
1 parent fb04f79 commit 84be6c2
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions frontend/components/Course/InstructorQueuePage/QuestionTimer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React, { useEffect } from "react";
import { Label } from "semantic-ui-react";
import timerAudio from "./timeupsound.mp3";
import { usePlayer } from "../../../hooks/player";
import { checkPermissions } from "../../../utils/notifications";

interface QuestionTimerProps {
questionStartTime: string;
Expand All @@ -14,7 +15,7 @@ const QuestionTimer = ({
const [, , play] = usePlayer(timerAudio);
const now = Date.now();
const diff =
(timerStartTime / 10) * 60 * 1000 -
timerStartTime * 60 * 1000 -
(now - new Date(questionStartTime).getTime());
const minutes = Math.floor(Math.abs(diff) / (1000 * 60));
const seconds = Math.floor((Math.abs(diff) % (1000 * 60)) / 1000);
Expand All @@ -23,9 +24,10 @@ const QuestionTimer = ({
// Play a sound effect when hit zero (once)
useEffect(() => {
if (minutes + seconds === 0) {
play.current(
`Timer is up! You have answered this question for ${timerStartTime} minute(s).`
);
if (!checkPermissions())
play.current(
`Timer is up! You have answered this question for ${timerStartTime} minute(s).`
);
}
}, [sign]);
const formated = `${sign}${minutes.toString().padStart(2, "0")}:${seconds
Expand Down

0 comments on commit 84be6c2

Please sign in to comment.