fix: Fix kanji card creation

This commit is contained in:
Dendy 2025-09-28 10:03:33 +02:00
parent bc2b3ac0b4
commit 5469ce7fec
2 changed files with 8 additions and 6 deletions

View File

@ -84,7 +84,8 @@ class CreateProductionCommand extends Command
$sNote = $this->ankiService->getNote($noteIds[array_key_last($noteIds)]); $sNote = $this->ankiService->getNote($noteIds[array_key_last($noteIds)]);
$newSlNote = SentenceListeningNote::fromNote($sNote, $term); $newSlNote = SentenceListeningNote::fromNote($sNote, $term);
if (!$this->ankiService->addNote($newSlNote, SentenceListeningNote::DECK)) { dd($newSlNote);
if (!$this->ankiService->addNote($newSlNote)) {
throw new \Exception('Failed to add note!'); throw new \Exception('Failed to add note!');
} }
} }

View File

@ -18,9 +18,10 @@ class SentenceListeningNote extends Note
} }
public function setTerm(Term $term): static public function setTerm(Term $term): static
{ {
$this->fields['Vocab'] = $term->getKanji(); $this->fields['VocabKanji'] = $term->getKanji();
$this->fields['VocabDef'] = $term->toAnkiVocabDef(); $this->fields['VocabFurigana'] = $term->getReading();
$this->fields['SentKanji'] = $this->stringHighlight( $this->fields['VocabDef'] = $term->toAnkiVocabDef();
$this->fields['SentKanji'] = $this->stringHighlight(
$this->fields['SentKanji'], $this->fields['SentKanji'],
$term->getKanji(), $term->getKanji(),
); );
@ -50,9 +51,9 @@ class SentenceListeningNote extends Note
return $note; return $note;
} }
public static function fromNote(Note $origNote, Term $term): static public static function fromNote(Note $origNote, Term $term): self
{ {
$slNote = new static(); $slNote = new self();
foreach (get_object_vars($origNote) as $prop => $value) { foreach (get_object_vars($origNote) as $prop => $value) {
$slNote->$prop = $value; $slNote->$prop = $value;
} }