From 2353c1fd1a8f40162ff2ce43779f11c47ebcd305 Mon Sep 17 00:00:00 2001 From: Dendy Faist Date: Thu, 6 Feb 2025 16:07:32 +0900 Subject: [PATCH] feat: Add method to AnkiService to get arbitrary notes from NIDs --- src/Service/AnkiService.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/Service/AnkiService.php b/src/Service/AnkiService.php index f33cef9..87ffaf6 100644 --- a/src/Service/AnkiService.php +++ b/src/Service/AnkiService.php @@ -58,14 +58,17 @@ class AnkiService return $this->getNotesInfo([$noteId])[0]; } + public function getNote(int $nid): ?Note + { + return Note::fromAnki($this->getNoteInfo($nid)); + } + public function getLatestNote(): ?Note { // NoteIDs are just timestamps in milliseconds, so the latest is just // the biggest numerically $latestId = max($this->getAllNoteIds()); - $noteInfo = $this->getNoteInfo($latestId); - - return Note::fromAnki($noteInfo); + return $this->getNote($latestId); } public function updateNote(Note $note)