Skip to content

deprecation(libanki): move to col.defaultsForAdding #19650

@david-allison

Description

@david-allison

/** Get current model.*/
@RustCleanup("Should use defaultsForAdding() instead")
fun current(forDeck: Boolean = true): NotetypeJson {
var noteType = get(col.decks.current().getLongOrNull("mid"))
if (!forDeck || noteType == null) {
noteType = get(col.config.get("curModel") ?: 1L)
}
if (noteType != null) {
return noteType
}
return get(allNamesAndIds().first().id)!!
}

/**
* Get starting deck and notetype for add screen.
* An option in the preferences controls whether this will be based on the current deck
* or current notetype.
*/
@CheckResult
@LibAnkiAlias("defaults_for_adding")
fun defaultsForAdding(currentReviewCard: Card? = null): anki.notes.DeckAndNotetype {
val homeDeck = currentReviewCard?.currentDeckId() ?: 0L
return backend.defaultsForAdding(homeDeckOfCurrentReviewCard = homeDeck)
}

and deprecate current()

https://github.com/ankitects/anki/blob/5614d20bedcc4dd268136d389ad796b404a69d2c/pylib/anki/models.py#L135-L142

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions