summaryrefslogtreecommitdiff
path: root/internal/gui
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-04-02 17:52:13 +0300
committerPaul Buetow <paul@buetow.org>2026-04-02 17:52:13 +0300
commit11a3e62f17433a7df0e6a77a688321d94a736778 (patch)
treeada0f94c074a3e290ea993179fbf645a40d7ab48 /internal/gui
parentf3d057fec20aeef584cb6340c6a002280a019f15 (diff)
task 003: handle home-dir and APKG marshal errors
Diffstat (limited to 'internal/gui')
-rw-r--r--internal/gui/app.go16
1 files changed, 13 insertions, 3 deletions
diff --git a/internal/gui/app.go b/internal/gui/app.go
index 60bc2e1..f9d941d 100644
--- a/internal/gui/app.go
+++ b/internal/gui/app.go
@@ -24,6 +24,7 @@ import (
"codeberg.org/snonux/totalrecall/internal/anki"
"codeberg.org/snonux/totalrecall/internal/archive"
"codeberg.org/snonux/totalrecall/internal/audio"
+ appconfig "codeberg.org/snonux/totalrecall/internal/config"
"codeberg.org/snonux/totalrecall/internal/image"
"codeberg.org/snonux/totalrecall/internal/phonetic"
"codeberg.org/snonux/totalrecall/internal/translation"
@@ -135,7 +136,10 @@ const (
// DefaultConfig returns default GUI configuration
func DefaultConfig() *Config {
- homeDir, _ := os.UserHomeDir()
+ homeDir, err := appconfig.HomeDir()
+ if err != nil {
+ fmt.Fprintf(os.Stderr, "Warning: %v\n", err)
+ }
// Use XDG Base Directory specification for state data
outputDir := filepath.Join(homeDir, ".local", "state", "totalrecall", "cards")
audioDefaults := audio.DefaultProviderConfig()
@@ -1362,7 +1366,10 @@ func (a *Application) onExportToAnki() {
deckNameEntry.SetPlaceHolder("Bulgarian Vocabulary")
// Export directory selection
- homeDir, _ := os.UserHomeDir()
+ homeDir, err := appconfig.HomeDir()
+ if err != nil {
+ fmt.Fprintf(os.Stderr, "Warning: %v\n", err)
+ }
defaultExportDir := homeDir // Changed from Downloads to home directory
selectedDir := defaultExportDir
@@ -1533,7 +1540,10 @@ func (a *Application) onArchive() {
// Function to perform the archive
performArchive := func() {
// Get the cards directory path
- home, _ := os.UserHomeDir()
+ home, err := appconfig.HomeDir()
+ if err != nil {
+ fmt.Fprintf(os.Stderr, "Warning: %v\n", err)
+ }
cardsDir := filepath.Join(home, ".local", "state", "totalrecall", "cards")
// Archive the cards