Kaynağa Gözat

:construction: completed save survey state on refresh

tags/0.0.3^2
tomit4 3 yıl önce
ebeveyn
işleme
fde10f8d54
1 değiştirilmiş dosya ile 6 ekleme ve 2 silme
  1. 6
    2
      frontend/src/views/OnboardingView.vue

+ 6
- 2
frontend/src/views/OnboardingView.vue Dosyayı Görüntüle

@@ -66,10 +66,12 @@ export default {
66 66
         // and redirects the user to their last unanswered survey question
67 67
         if (localStorage['currentStep'] &&
68 68
             localStorage['currentProfileId'] &&
69
-            localStorage['responses']) {
69
+            localStorage['responses'] &&
70
+            localStorage['answered']) {
70 71
             this.currentStep = Number(localStorage['currentStep'])
71 72
             this.currentProfileId = Number(localStorage['currentProfileId'])
72 73
             this.responses = JSON.parse(localStorage['responses'])
74
+            this.answered = JSON.parse(localStorage['answered'])
73 75
             this.goToStep(this.currentStep)
74 76
         }
75 77
     },
@@ -101,6 +103,9 @@ export default {
101 103
                 response.response_key_id = payload.question.response_key_id
102 104
                 response.val = payload.input
103 105
                 this.responses.push(response)
106
+                // save user's progress through survey
107
+                localStorage.setItem('responses', JSON.stringify(this.responses))
108
+                localStorage.setItem('answered', JSON.stringify(this.answered))
104 109
 
105 110
                 // sends latest survey response to db
106 111
                 if (this.currentProfileId) {
@@ -118,7 +123,6 @@ export default {
118 123
                     this.currentProfileId = newProfile.profile_id
119 124
                     // save user's progress through survey
120 125
                     localStorage.setItem('currentProfileId', Number(newProfile.profile_id))
121
-                    localStorage.setItem('responses', JSON.stringify(this.responses))
122 126
                 }
123 127
 
124 128
                 if (k === 'aspects') return

Loading…
İptal
Kaydet