Jelajahi Sumber

fix refresh bug

Arsekl 3 tahun lalu
induk
melakukan
0db0520ef9
1 mengubah file dengan 4 tambahan dan 1 penghapusan
  1. 4 1
      src/utils/index.ts

+ 4 - 1
src/utils/index.ts

@@ -273,15 +273,18 @@ export function getQuestion(examId: string, studentId: string) {
             response => {
                 hide()
                 if (response.err === 0) {
-                    store.dispatch(loadQuestion(response.res));
                     const question = response.res;
                     const current = store.getState().loadCurrentQuestion;
                     if (Object.keys(current).length === 0) {
+                        store.dispatch(loadQuestion(question));
                         store.dispatch(loadCurrentQuestion(response.res.codeList[0]));
                         generateFileTree(response.res.codeList[0]);
                     } else {
                         for (let i = 0; i < question.codeList.length; i++){
                             if (question.codeList[i].questionId === current.questionId) {
+                                const pre = store.getState().loadQuestion;
+                                if (pre && pre.codeList) pre.codeList[i] = question.codeList[i];
+                                store.dispatch(loadQuestion(pre));
                                 store.dispatch(loadCurrentQuestion(question.codeList[i]));
                                 generateFileTree(question.codeList[i]);
                                 break;