Skip to content

Commit

Permalink
feat(DamageCalculatorPage): init all databases in component setup
Browse files Browse the repository at this point in the history
  • Loading branch information
rudnovd committed Oct 10, 2021
1 parent 1e64625 commit f129cdc
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/views/DamageCalculatorPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ import type { Ref } from 'vue'
import { useI18n } from 'vue-i18n'
import DamageCalculator from '@/components/DamageCalculator.vue'
import { Battle } from '@/models/Battle'
import { getDatabaseStore, initDatabaseStore } from '@/database'
export default defineComponent({
name: 'DamageCalculatorPage',
Expand All @@ -71,6 +72,19 @@ export default defineComponent({
const attacker = computed(() => calculators.value[activeIndex.value].attacker)
const defender = computed(() => calculators.value[activeIndex.value].defender)
getDatabaseStore("creatures").then((creatures) => {
if (!creatures.length) {
initDatabaseStore("classes")
initDatabaseStore("creatures")
initDatabaseStore("heroes")
initDatabaseStore("levels")
initDatabaseStore("skills")
initDatabaseStore("spells")
initDatabaseStore("terrains")
initDatabaseStore("towns")
}
})
watch(
[attacker, defender],
() => {
Expand Down

0 comments on commit f129cdc

Please sign in to comment.