summaryrefslogtreecommitdiff
path: root/internal/gui/navigation.go
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2025-07-22 16:03:13 +0300
committerPaul Buetow <paul@buetow.org>2025-07-22 16:03:13 +0300
commit18a475657cbc7b2ff8ee537b082eeef25e9bf619 (patch)
tree9295ccbd3e6e0f45f2ab361acc5800197de6265f /internal/gui/navigation.go
parentdf496b9888ec29bc86d2b5a8ebee1782e94e49f9 (diff)
Fix race conditions in background processing and prevent deletion of active cards
- Fix race condition where images, audio, and phonetic info could be saved to wrong flashcard when navigating quickly between cards - Add pre-determined card directory that's passed to all background operations - Track active operations per word to prevent deletion during generation - Block deletion of cards that are queued or being processed - Show appropriate error messages when deletion is blocked This ensures files are always saved to the correct card directory and prevents data loss from deleting cards with active operations. 🤖 Generated with [opencode](https://opencode.ai) Co-Authored-By: opencode <noreply@opencode.ai>
Diffstat (limited to 'internal/gui/navigation.go')
-rw-r--r--internal/gui/navigation.go12
1 files changed, 12 insertions, 0 deletions
diff --git a/internal/gui/navigation.go b/internal/gui/navigation.go
index c91a57a..d7410f1 100644
--- a/internal/gui/navigation.go
+++ b/internal/gui/navigation.go
@@ -580,6 +580,18 @@ func (a *Application) onDelete() {
return
}
+ // Check if this word has active operations
+ if a.hasActiveOperations(a.currentWord) {
+ dialog.ShowError(fmt.Errorf("Cannot delete '%s' while content is being generated.\nPlease wait for generation to complete.", a.currentWord), a.window)
+ return
+ }
+
+ // Also check if word is in the processing queue
+ if a.queue.IsWordProcessing(a.currentWord) {
+ dialog.ShowError(fmt.Errorf("Cannot delete '%s' while it is in the processing queue.\nPlease wait for processing to complete.", a.currentWord), a.window)
+ return
+ }
+
// Create custom confirmation dialog with keyboard support
message := fmt.Sprintf("Move all files for '%s' to trash?\n\nPress y to confirm or n to cancel", a.currentWord)
confirmDialog := dialog.NewConfirm("Move to Trash", message, func(confirm bool) {