Skip to content

Commit

Permalink
Remove timer useEffect for refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
mpbrown committed Jul 11, 2024
1 parent 7404252 commit c0adf16
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 13 deletions.
14 changes: 2 additions & 12 deletions frontend/src/app/testQueue/TestCard/TestCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,18 +71,6 @@ export const TestCard = ({
}
};

// when the test order has a new timer started at value, check if we need to clear the timer
// this happens when another user stops a timer, so to keep it in sync
// we need to stop it for any other users viewing the same queue
useEffect(() => {
if (
testOrder.timerStartedAt === null ||
testOrder.timerStartedAt === undefined
) {
timer.reset(trackTimerReset);
}
}, [testOrder.timerStartedAt]);

useEffect(() => {
if (startTestPatientId === testOrder.patient.internalId) {
testCardElement.current.scrollIntoView({ behavior: "smooth" });
Expand Down Expand Up @@ -114,6 +102,8 @@ export const TestCard = ({
if (startedAt === undefined) {
timer.reset(trackTimerReset);
testOrder.timerStartedAt = "0";
} else {
testOrder.timerStartedAt = startedAt?.toString();
}
};

Expand Down
9 changes: 8 additions & 1 deletion frontend/src/app/testQueue/TestTimer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,15 @@ export const useTestTimer = (
startedAt: number = 0
) => {
const [, setCount] = useState(0);
const existingTimer = findTimer(id);
if (existingTimer && startedAt == 0) {

Check warning on line 182 in frontend/src/app/testQueue/TestTimer.tsx

View workflow job for this annotation

GitHub Actions / check-graphql-types

Expected '===' and instead saw '=='
// if timer already exists and startedAt is 0,
// then reset the timer
existingTimer.reset();
saveTimers();
}
const timer: Timer = findTimer(id) || addTimer(id, testLength);
if (startedAt !== null && startedAt !== undefined && startedAt !== 0) {
if (!!startedAt) {
timer.setStartedAt(startedAt);
}
useEffect(() => {
Expand Down

0 comments on commit c0adf16

Please sign in to comment.