chore: lint and fmt
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
<script lang="ts" setup>
|
||||
import { computed, ref } from 'vue'
|
||||
import { computed, ref } from "vue"
|
||||
|
||||
import FlipCard from '@/modules/card/components/FlipCard.vue'
|
||||
import { Repetition } from '@/modules/card/hooks/useSpacedRepetitionCards'
|
||||
import FlipCard from "@/modules/card/components/FlipCard.vue"
|
||||
import { Repetition } from "@/modules/card/hooks/useSpacedRepetitionCards"
|
||||
|
||||
const props = defineProps<{ cards: Repetition[] }>()
|
||||
const emits = defineEmits<{
|
||||
@@ -22,24 +22,24 @@ const sortedCards = ref(
|
||||
const currentIndex = ref(0)
|
||||
|
||||
const goToNextCard = (success: boolean) => {
|
||||
const id = sortedCards.value[currentIndex.value].repetition._id ?? ''
|
||||
const id = sortedCards.value[currentIndex.value].repetition._id ?? ""
|
||||
|
||||
if (success) {
|
||||
emits('success', id)
|
||||
emits("success", id)
|
||||
} else {
|
||||
const failedCard = sortedCards.value.at(currentIndex.value)
|
||||
if (failedCard) {
|
||||
sortedCards.value.push(failedCard)
|
||||
}
|
||||
emits('fail', id)
|
||||
emits("fail", id)
|
||||
}
|
||||
|
||||
currentIndex.value++
|
||||
}
|
||||
|
||||
const needsReview = () => {
|
||||
const id = sortedCards.value[currentIndex.value].repetition._id ?? ''
|
||||
emits('needsReview', id)
|
||||
const id = sortedCards.value[currentIndex.value].repetition._id ?? ""
|
||||
emits("needsReview", id)
|
||||
currentIndex.value++
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { useAsyncState } from '@vueuse/core'
|
||||
import { useAsyncState } from "@vueuse/core"
|
||||
|
||||
import { data } from '@/data/data'
|
||||
import { DataType } from '@/data/DataType.enum'
|
||||
import { RepetitionCard } from '@/modules/card/models/RepetitionCard'
|
||||
import { data } from "@/data/data"
|
||||
import { DataType } from "@/data/DataType.enum"
|
||||
import { RepetitionCard } from "@/modules/card/models/RepetitionCard"
|
||||
|
||||
export const useNeedReviewCards = () => {
|
||||
const { state: cardsToReview, isReady } = useAsyncState(async () => {
|
||||
|
||||
@@ -31,14 +31,14 @@ export const useSpacedRepetitionCards = () => {
|
||||
(file) =>
|
||||
file.path !== undefined &&
|
||||
file.path.startsWith("_cards") &&
|
||||
file.path.endsWith(".md"),
|
||||
),
|
||||
file.path.endsWith(".md")
|
||||
)
|
||||
)
|
||||
|
||||
const {
|
||||
state: cards,
|
||||
isReady,
|
||||
execute,
|
||||
execute
|
||||
} = useAsyncState(
|
||||
async () => {
|
||||
const cards: Repetition[] = []
|
||||
@@ -55,7 +55,7 @@ export const useSpacedRepetitionCards = () => {
|
||||
$type: DataType.RepetitionCard,
|
||||
level: 1,
|
||||
repeatDate: new Date(),
|
||||
needsReview: false,
|
||||
needsReview: false
|
||||
})
|
||||
|
||||
if (
|
||||
@@ -77,20 +77,20 @@ export const useSpacedRepetitionCards = () => {
|
||||
card: {
|
||||
front: toHTML(front),
|
||||
back: toHTML(back),
|
||||
references: toHTML(references),
|
||||
},
|
||||
references: toHTML(references)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
return cards
|
||||
},
|
||||
[],
|
||||
{ immediate: false },
|
||||
{ immediate: false }
|
||||
)
|
||||
|
||||
const successRepetition = async (cardId: string) => {
|
||||
const repetition = await data.get<DataType.RepetitionCard, RepetitionCard>(
|
||||
cardId,
|
||||
cardId
|
||||
)
|
||||
if (!repetition) {
|
||||
return
|
||||
@@ -100,13 +100,13 @@ export const useSpacedRepetitionCards = () => {
|
||||
...repetition,
|
||||
needsReview: false,
|
||||
level: Math.min(repetition.level + 1, MAX_LEVEL),
|
||||
repeatDate: addDays(new Date(), 2 ** repetition.level),
|
||||
repeatDate: addDays(new Date(), 2 ** repetition.level)
|
||||
})
|
||||
}
|
||||
|
||||
const failRepetition = async (cardId: string) => {
|
||||
const repetition = await data.get<DataType.RepetitionCard, RepetitionCard>(
|
||||
cardId,
|
||||
cardId
|
||||
)
|
||||
if (!repetition) {
|
||||
return
|
||||
@@ -118,13 +118,13 @@ export const useSpacedRepetitionCards = () => {
|
||||
...repetition,
|
||||
level,
|
||||
needsReview: false,
|
||||
repeatDate: addDays(new Date(), level),
|
||||
repeatDate: addDays(new Date(), level)
|
||||
})
|
||||
}
|
||||
|
||||
const needsReview = async (cardId: string) => {
|
||||
const repetition = await data.get<DataType.RepetitionCard, RepetitionCard>(
|
||||
cardId,
|
||||
cardId
|
||||
)
|
||||
if (!repetition) {
|
||||
return
|
||||
@@ -132,7 +132,7 @@ export const useSpacedRepetitionCards = () => {
|
||||
|
||||
await data.update<DataType.RepetitionCard, RepetitionCard>({
|
||||
...repetition,
|
||||
needsReview: true,
|
||||
needsReview: true
|
||||
})
|
||||
}
|
||||
|
||||
@@ -142,7 +142,7 @@ export const useSpacedRepetitionCards = () => {
|
||||
nextTick(() => {
|
||||
listenToClick()
|
||||
}),
|
||||
{ immediate: true },
|
||||
{ immediate: true }
|
||||
)
|
||||
|
||||
watch(cardFiles, () => execute())
|
||||
@@ -152,6 +152,6 @@ export const useSpacedRepetitionCards = () => {
|
||||
successRepetition,
|
||||
failRepetition,
|
||||
needsReview,
|
||||
isLoading: !isReady,
|
||||
isLoading: !isReady
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { DataType } from '@/data/DataType.enum'
|
||||
import { Model } from '@/data/models/Model'
|
||||
import { DataType } from "@/data/DataType.enum"
|
||||
import { Model } from "@/data/models/Model"
|
||||
|
||||
export interface RepetitionCard extends Model<DataType.RepetitionCard> {
|
||||
level: number
|
||||
|
||||
Reference in New Issue
Block a user