Skip to content

Commit e7b49a6

Browse files
committed
Kotlin did not recognize a java nullable return, hence my AnkiDAO assumed the result of the function to always be non null, which caused a null exception if the note in Anki had been removed. Second bug for anki failures (issue #65).
1 parent 0a5d2d9 commit e7b49a6

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

crossPlatform/src/androidMain/kotlin/fr/berliat/hskwidget/data/dao/AnkiDAO.android.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,10 @@ actual class AnkiDAO(context: Context) {
106106
}
107107

108108
actual suspend fun getNote(noteId: Long): AnkiNoteInfo? =
109-
withContext(Dispatchers.IO) { AnkiNoteInfo(api.getNote(noteId)) }
109+
withContext(Dispatchers.IO) {
110+
// Even if Kotlin recognize as NoteInfo!, it's not correct, should be NoteInfo?
111+
api.getNote(noteId)?.let { AnkiNoteInfo(it) }
112+
}
110113
actual suspend fun addNote(modelId: Long, deckId: Long, fields: Array<String>, tags: Set<String>?): Long?
111114
= withContext(Dispatchers.IO) { api.addNote(modelId, deckId, fields, tags) }
112115
actual suspend fun updateNoteTags(noteId: Long, tags: Set<String>): Boolean

0 commit comments

Comments
 (0)