✨ (card) limit to max level and sort by level max to min
This commit is contained in:
@@ -9,7 +9,11 @@ const emits = defineEmits<{
|
|||||||
fail: [id: string]
|
fail: [id: string]
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
const cards = ref(props.cards)
|
const cards = ref(
|
||||||
|
[...props.cards].sort((a, b) =>
|
||||||
|
a.repetition.level > b.repetition.level ? -1 : 1
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
const currentIndex = ref(0)
|
const currentIndex = ref(0)
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
// https://npm.io/package/supermemo
|
||||||
|
|
||||||
import { DataType } from '@/data/DataType.enum'
|
import { DataType } from '@/data/DataType.enum'
|
||||||
import { data } from '@/data/data'
|
import { data } from '@/data/data'
|
||||||
import { useFile } from '@/hooks/useFile.hook'
|
import { useFile } from '@/hooks/useFile.hook'
|
||||||
@@ -11,7 +13,7 @@ import { useAsyncState } from '@vueuse/core'
|
|||||||
import { addDays, isAfter } from 'date-fns'
|
import { addDays, isAfter } from 'date-fns'
|
||||||
import { computed, nextTick, watch } from 'vue'
|
import { computed, nextTick, watch } from 'vue'
|
||||||
|
|
||||||
const MAX_LEVEL = 10
|
const MAX_LEVEL = 8
|
||||||
|
|
||||||
export interface Repetition {
|
export interface Repetition {
|
||||||
repetition: RepetitionCard
|
repetition: RepetitionCard
|
||||||
@@ -54,7 +56,10 @@ export const useSpacedRepetitionCards = () => {
|
|||||||
repeatDate: new Date()
|
repeatDate: new Date()
|
||||||
})
|
})
|
||||||
|
|
||||||
if (isAfter(new Date(repetition.repeatDate), new Date())) {
|
if (
|
||||||
|
isAfter(new Date(repetition.repeatDate), new Date()) ||
|
||||||
|
repetition.level === MAX_LEVEL
|
||||||
|
) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -88,12 +93,10 @@ export const useSpacedRepetitionCards = () => {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const newLevel = repetition.level + 1
|
|
||||||
|
|
||||||
await data.update<DataType.RepetitionCard, RepetitionCard>({
|
await data.update<DataType.RepetitionCard, RepetitionCard>({
|
||||||
...repetition,
|
...repetition,
|
||||||
level: Math.min(newLevel, MAX_LEVEL),
|
level: Math.min(repetition.level + 1, MAX_LEVEL),
|
||||||
repeatDate: addDays(new Date(), newLevel)
|
repeatDate: addDays(new Date(), 2 ** repetition.level)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
const failRepetition = async (cardId: string) => {
|
const failRepetition = async (cardId: string) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user