Skip to content

Commit

Permalink
fix multiple code saved messages and submission or test case running …
Browse files Browse the repository at this point in the history
…forever on error
  • Loading branch information
solomonng2001 committed Nov 14, 2024
1 parent e5642a7 commit 559af68
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 30 deletions.
64 changes: 35 additions & 29 deletions apps/frontend/src/app/collaboration/[id]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -238,16 +238,19 @@ export default function CollaborationPage(props: CollaborationProps) {
}
setIsLoadingTestCase(true);
sendExecutingStateToMatchedUser(true);
const data = await ExecuteVisibleAndCustomTests(questionDocRefId, {
code: code,
language: selectedLanguage,
customTestCases: "",
});
updateExecutionResults(data);
infoMessage("Test cases executed. Review the results below.");
sendExecutionResultsToMatchedUser(data);
setIsLoadingTestCase(false);
sendExecutingStateToMatchedUser(false);
try {
const data = await ExecuteVisibleAndCustomTests(questionDocRefId, {
code: code,
language: selectedLanguage,
customTestCases: "",
});
updateExecutionResults(data);
successMessage("Test cases executed. Review the results below.");
sendExecutionResultsToMatchedUser(data);
} finally {
setIsLoadingTestCase(false);
sendExecutingStateToMatchedUser(false);
}
};

const handleSubmitCode = async () => {
Expand All @@ -256,25 +259,28 @@ export default function CollaborationPage(props: CollaborationProps) {
}
setIsLoadingSubmission(true);
sendSubmittingStateToMatchedUser(true);
const data = await ExecuteVisibleAndHiddenTestsAndSubmit(questionDocRefId, {
code: code,
language: selectedLanguage,
user: currentUser ?? "",
matchedUser: matchedUser ?? "",
matchedTopics: matchedTopics ?? [],
title: questionTitle ?? "",
questionDifficulty: complexity ?? "",
questionTopics: categories,
});
updateExecutionResults({
visibleTestResults: data.visibleTestResults,
customTestResults: [],
});
updateSubmissionResults(data);
sendSubmissionResultsToMatchedUser(data);
successMessage("Code saved successfully!");
setIsLoadingSubmission(false);
sendSubmittingStateToMatchedUser(false);
try {
const data = await ExecuteVisibleAndHiddenTestsAndSubmit(questionDocRefId, {
code: code,
language: selectedLanguage,
user: currentUser ?? "",
matchedUser: matchedUser ?? "",
matchedTopics: matchedTopics ?? [],
title: questionTitle ?? "",
questionDifficulty: complexity ?? "",
questionTopics: categories,
});
updateExecutionResults({
visibleTestResults: data.visibleTestResults,
customTestResults: [],
});
updateSubmissionResults(data);
sendSubmissionResultsToMatchedUser(data);
successMessage("Code saved successfully!");
} finally {
setIsLoadingSubmission(false);
sendSubmittingStateToMatchedUser(false);
}
};

const handleCodeChange = (code: string) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ const CollaborativeEditor = forwardRef(
state.editorState &&
state.editorState.id !== latestLanguageChangeId
) {
latestSubmissionId = state.editorState.id;
latestLanguageChangeId = state.editorState.id;
setSelectedLanguage(state.editorState.language);
// if (props.user === state.user.name) {
// console.log("ownself update ownself");
Expand Down

0 comments on commit 559af68

Please sign in to comment.