fix where you could have 0 decks in flashcards

This commit is contained in:
RezHackXYZ 2025-06-13 17:26:13 +05:30
parent 2e09e54b18
commit b470cf0e39
No known key found for this signature in database
GPG key ID: C4C90E569C9669E2

View file

@ -87,7 +87,9 @@
<div class="flex gap-3"> <div class="flex gap-3">
<button <button
onclick={() => { onclick={() => {
if (confirm("Are you sure you want to delete this deck?")) { if (deck.length == 2) {
toast.error("You need to have at least 1 deck");
} else if (confirm("Are you sure you want to delete this deck?")) {
deck.splice(CurrentlyEditingDeckId, 1); deck.splice(CurrentlyEditingDeckId, 1);
CurrentlyEditingDeckId = Math.max(0, CurrentlyEditingDeckId - 1); CurrentlyEditingDeckId = Math.max(0, CurrentlyEditingDeckId - 1);
DeckOptions.value = CurrentlyEditingDeckId.toString(); DeckOptions.value = CurrentlyEditingDeckId.toString();