Skip to content

Commit

Permalink
only add new answers to state (#316)
Browse files Browse the repository at this point in the history
* only add new answers to state

* fix 1 test

* fix

---------

Co-authored-by: Aaron Shiel <[email protected]>
  • Loading branch information
aaronshiel and Aaron Shiel authored Feb 14, 2024
1 parent fbb401c commit 91b8adc
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
10 changes: 7 additions & 3 deletions client/src/hooks/graphql/use-with-record-state.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -139,13 +139,16 @@ export function useWithRecordState(
}
}

// Insert answers that are not already in state
const answerStates: AnswerState[] = [];
for (const a of _answers) {
const q = getValueIfKeyExists(a.question, mentorQuestions);
// we don't want to remove questions that are already in the recording state
const answerAlreadyInState = Boolean(
answers.find((as) => as.answer.question === a.question)
const answerInState = answers.find(
(as) => as.answer.question === a.question
);

const answerAlreadyInState = Boolean(answerInState);
let checkStatus = !status || answerAlreadyInState;
if (status === Status.COMPLETE) {
checkStatus =
Expand All @@ -167,10 +170,11 @@ export function useWithRecordState(
answer: a,
editedAnswer: a,
editedQuestion: q.question,
recordedVideo: undefined,
recordedVideo: answerInState?.recordedVideo || undefined,
minVideoLength: q.question.minVideoLength,
attentionNeeded: doesAnswerNeedAttention(a),
localTranscriptChanges: false,
...(answerInState || {}),
});
}
}
Expand Down
8 changes: 7 additions & 1 deletion cypress/cypress/e2e/home.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1184,7 +1184,13 @@ describe("My Mentor Page", () => {
it("users with locked subjects cannot see 'select subject' in hamburger menu", () => {
cySetup(cy);
cyMockDefault(cy, {
mentor: clintWithConfig,
mentor: {
...clintWithConfig,
mentorConfig: {
...clintWithConfig.mentorConfig,
lockedToSubjects: true,
},
},
});
cy.visit("/");
cy.get("[data-cy=setup-no]").trigger("mouseover").click();
Expand Down

0 comments on commit 91b8adc

Please sign in to comment.