summaryrefslogtreecommitdiff
path: root/internal/gui/persistence.go
blob: dc05b3663c26b36beca4d245b82e92410d25338d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package gui

import (
	"fmt"
)

// ensureCardDirectory ensures a card directory exists for the given word.
// Delegates to CardService.
func (a *Application) ensureCardDirectory(word string) (string, error) {
	return a.getCardService().EnsureCardDirectory(word)
}

// saveTranslation saves the current translation to disk.
// Delegates to CardService.
func (a *Application) saveTranslation() {
	if err := a.getCardService().SaveTranslation(a.currentWord, a.currentTranslation); err != nil {
		a.showError(err)
	}
}

// saveImagePrompt is retained for compatibility but is currently a no-op.
// The image prompt is saved by the image generation callback when the image
// is generated, so there is no need to save it separately here.
func (a *Application) saveImagePrompt() {
	// No-op: the prompt is saved as soon as it is generated via the callback.
}

// savePhoneticInfo saves the current phonetic information to disk.
// Delegates to CardService.
func (a *Application) savePhoneticInfo() {
	if err := a.getCardService().SavePhoneticInfo(a.currentWord, a.currentPhonetic); err != nil {
		a.showError(fmt.Errorf("failed to save phonetic info: %w", err))
	}
}