Skip to content

Commit e23725b

Browse files
committed
resolve merge conflicts
2 parents 542f9bb + e5642a7 commit e23725b

File tree

1 file changed

+24
-11
lines changed
  • apps/frontend/src/app/collaboration/[id]

1 file changed

+24
-11
lines changed

apps/frontend/src/app/collaboration/[id]/page.tsx

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -217,15 +217,19 @@ export default function CollaborationPage(props: CollaborationProps) {
217217
};
218218

219219
const updateSubmissionResults = (data: SubmissionResults) => {
220-
setSubmissionHiddenTestResultsAndStatus({
220+
const submissionHiddenTestResultsAndStatus: SubmissionHiddenTestResultsAndStatus = {
221221
hiddenTestResults: data.hiddenTestResults,
222222
status: data.status,
223-
});
223+
}
224+
setSubmissionHiddenTestResultsAndStatus(submissionHiddenTestResultsAndStatus);
225+
localStorage.setItem("submissionHiddenTestResultsAndStatus", JSON.stringify(submissionHiddenTestResultsAndStatus));
224226
setVisibleTestCases(data.visibleTestResults);
227+
localStorage.setItem("visibleTestResults", JSON.stringify(data.visibleTestResults));
225228
};
226229

227230
const updateExecutionResults = (data: ExecutionResults) => {
228231
setVisibleTestCases(data.visibleTestResults);
232+
localStorage.setItem("visibleTestResults", JSON.stringify(data.visibleTestResults));
229233
};
230234

231235
const updateLangauge = (data: string) => {
@@ -244,7 +248,7 @@ export default function CollaborationPage(props: CollaborationProps) {
244248
language: selectedLanguage,
245249
customTestCases: "",
246250
});
247-
setVisibleTestCases(data.visibleTestResults);
251+
updateExecutionResults(data);
248252
infoMessage("Test cases executed. Review the results below.");
249253
sendExecutionResultsToMatchedUser(data);
250254
} finally {
@@ -270,11 +274,11 @@ export default function CollaborationPage(props: CollaborationProps) {
270274
questionDifficulty: complexity ?? "",
271275
questionTopics: categories,
272276
});
273-
setVisibleTestCases(data.visibleTestResults);
274-
setSubmissionHiddenTestResultsAndStatus({
275-
hiddenTestResults: data.hiddenTestResults,
276-
status: data.status,
277+
updateExecutionResults({
278+
visibleTestResults: data.visibleTestResults,
279+
customTestResults: [],
277280
});
281+
updateSubmissionResults(data);
278282
sendSubmissionResultsToMatchedUser(data);
279283
successMessage("Code saved successfully!");
280284
} finally {
@@ -301,13 +305,20 @@ export default function CollaborationPage(props: CollaborationProps) {
301305
const currentUser: string = localStorage.getItem("user") ?? "";
302306
const matchedTopics: string[] =
303307
localStorage.getItem("matchedTopics")?.split(",") ?? [];
308+
const submissionHiddenTestResultsAndStatus: SubmissionHiddenTestResultsAndStatus | undefined =
309+
localStorage.getItem("submissionHiddenTestResultsAndStatus")
310+
? JSON.parse(localStorage.getItem("submissionHiddenTestResultsAndStatus") as string)
311+
: undefined;
312+
const visibleTestCases: Test[] = JSON.parse(localStorage.getItem("visibleTestResults") ?? "[]") ?? [];
304313

305314
// Set states from localstorage
306315
setCollaborationId(collabId);
307316
setMatchedUser(matchedUser);
308317
setCurrentUser(currentUser);
309318
setMatchedTopics(matchedTopics);
310319
setQuestionDocRefId(questionDocRefId);
320+
setSubmissionHiddenTestResultsAndStatus(submissionHiddenTestResultsAndStatus);
321+
setVisibleTestCases(visibleTestCases);
311322

312323
GetSingleQuestion(questionDocRefId).then((data: Question) => {
313324
setQuestionTitle(`${data.id}. ${data.title}`);
@@ -316,13 +327,13 @@ export default function CollaborationPage(props: CollaborationProps) {
316327
setDescription(data.description);
317328
});
318329

319-
GetVisibleTests(questionDocRefId)
320-
.then((data: Test[]) => {
330+
if (visibleTestCases.length == 0) {
331+
GetVisibleTests(questionDocRefId).then((data: Test[]) => {
321332
setVisibleTestCases(data);
322-
})
323-
.catch((e) => {
333+
}).catch((e) => {
324334
errorMessage(e.message);
325335
});
336+
}
326337

327338
// Start stopwatch
328339
startStopwatch();
@@ -406,6 +417,8 @@ export default function CollaborationPage(props: CollaborationProps) {
406417
localStorage.removeItem("collabId");
407418
localStorage.removeItem("questionDocRefId");
408419
localStorage.removeItem("matchedTopics");
420+
localStorage.removeItem("submissionHiddenTestResultsAndStatus");
421+
localStorage.removeItem("visibleTestResults");
409422
localStorage.removeItem("editor-language"); // Remove editor language type when session closed
410423
};
411424

0 commit comments

Comments
 (0)