Skip to content

Fix Questions.vue crash when DataSize is not loaded#20

Open
rahul810050 wants to merge 2 commits intooaiedu:masterfrom
rahul810050:fix/questions-datasize-guard
Open

Fix Questions.vue crash when DataSize is not loaded#20
rahul810050 wants to merge 2 commits intooaiedu:masterfrom
rahul810050:fix/questions-datasize-guard

Conversation

@rahul810050
Copy link

@rahul810050 rahul810050 commented Jan 29, 2026

Fixed issue: #19

PR Summary

This PR fixes a runtime crash in Questions.vue caused by accessing
getDataSize.questions.general before the Firestore DataSize document
is fully loaded.

Root cause

  • getDataSize is loaded asynchronously
  • Questions.vue accessed nested properties during render and mounted()
  • This resulted in TypeError: Cannot read properties of null

Solution

  • Added defensive guards to the pageAmount computed property
  • Introduced a hasDataSize reactive guard
  • Deferred the initial page load using a watcher instead of mounted()

Why this approach

  • Prevents race conditions between Firestore and Vue lifecycle
  • Matches existing fixes applied to Tests.vue and DataAmount.vue
  • Keeps store logic unchanged
  • Fully compatible with Vue 2 and Vuex

Affected files

  • src/components/Questions/Questions.vue

Result

  • Questions page no longer crashes on initial load
  • Pagination renders correctly
  • Page data loads only when DataSize is ready

Before:
image

After:
image

Fixed another issue :

Problem:

  • it shows no questions even if you have questions---it only shows when you filter it
image

after changes:

  • the question page will show all the questions it has..and the filter works fine as before
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant