Skip to content

Commit

Permalink
fix: not knowing when word knowledge is done
Browse files Browse the repository at this point in the history
  • Loading branch information
BrewingWeasel committed Aug 25, 2024
1 parent d2dcdd3 commit 32c26a3
Showing 1 changed file with 21 additions and 3 deletions.
24 changes: 21 additions & 3 deletions src/pages/settings/components/WordKnowledge.vue
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import { invoke } from "@tauri-apps/api/core";
import { toast } from "vue-sonner";
import StyledCombobox from "@/components/StyledCombobox.vue";
import { ref } from "vue";
import { Pencil, Plus, X } from "lucide-vue-next";
import { Loader2, Pencil, Plus, X } from "lucide-vue-next";
import Notes from "./Notes.vue";
import { Deck } from "@/types";
import BetterTooltip from "@/components/BetterTooltip.vue";
Expand Down Expand Up @@ -60,14 +60,32 @@ function addNote(deck_index: number) {
notesOpen.value[deck_index].push(true);
}
function refreshAnki(forceAll: boolean) {
invoke("refresh_anki", { forceAll }).catch((e) => {
const isRefreshing = ref(false);
const canClose = ref(false);
async function refreshAnki(forceAll: boolean) {
isRefreshing.value = true;
await invoke("refresh_anki", { forceAll }).catch((e) => {
toast.error(e);
});
canClose.value = true;
}
</script>

<template>
<AlertDialog v-model:open="isRefreshing">
<AlertDialogContent>
<AlertDialogHeader>
<AlertDialogTitle>Refresh Anki</AlertDialogTitle>
</AlertDialogHeader>
<div v-if="!canClose">
<Loader2 class="animate-spin" />
</div>
<AlertDialogFooter>
<AlertDialogAction v-if="canClose">Continue</AlertDialogAction>
</AlertDialogFooter>
</AlertDialogContent>
</AlertDialog>
<div class="py-2">
<Button variant="outline" class="mr-2" @click="refreshAnki(false)"
>Refresh Anki knowledge</Button
Expand Down

0 comments on commit 32c26a3

Please sign in to comment.