feat: Add method to AnkiService to get arbitrary notes from NIDs

This commit is contained in:
Dendy 2025-02-06 16:07:32 +09:00
parent e5f893a43d
commit 2353c1fd1a
1 changed files with 6 additions and 3 deletions

View File

@ -58,14 +58,17 @@ class AnkiService
return $this->getNotesInfo([$noteId])[0]; return $this->getNotesInfo([$noteId])[0];
} }
public function getNote(int $nid): ?Note
{
return Note::fromAnki($this->getNoteInfo($nid));
}
public function getLatestNote(): ?Note public function getLatestNote(): ?Note
{ {
// NoteIDs are just timestamps in milliseconds, so the latest is just // NoteIDs are just timestamps in milliseconds, so the latest is just
// the biggest numerically // the biggest numerically
$latestId = max($this->getAllNoteIds()); $latestId = max($this->getAllNoteIds());
$noteInfo = $this->getNoteInfo($latestId); return $this->getNote($latestId);
return Note::fromAnki($noteInfo);
} }
public function updateNote(Note $note) public function updateNote(Note $note)