Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 11 additions & 8 deletions AnkiDroid/src/main/java/com/ichi2/anki/NoteEditorFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -1232,13 +1232,15 @@ class NoteEditorFragment :
// ----------------------------------------------------------------------------

@KotlinCleanup("return early and simplify if possible")
private fun onNoteAdded() {
private fun onNoteAdded(count: Int) {
var closeEditorAfterSave = false
var closeIntent: Intent? = null
changed = true
sourceText = null
refreshNoteData(FieldChangeType.refreshWithStickyFields(shouldReplaceNewlines()))
showSnackbar(TR.addingAdded(), Snackbar.LENGTH_SHORT)
// backend text ends with dot
val successMessage = TR.importingCardsAdded(count).replace(".", "")
showSnackbar(successMessage, Snackbar.LENGTH_SHORT)

if (caller == NoteEditorCaller.NOTEEDITOR || aedictIntent) {
closeEditorAfterSave = true
Expand All @@ -1263,14 +1265,15 @@ class NoteEditorFragment :

private suspend fun saveNoteWithProgress() {
// adding current note to collection
requireActivity().withProgress(resources.getString(R.string.saving_facts)) {
undoableOp {
notetypes.save(editorNote!!.notetype)
addNote(editorNote!!, deckId)
val changes =
requireActivity().withProgress(resources.getString(R.string.saving_facts)) {
undoableOp {
notetypes.save(editorNote!!.notetype)
addNote(editorNote!!, deckId)
}
}
}
// update UI based on the result, noOfAddedCards
onNoteAdded()
onNoteAdded(changes.count)
updateFieldsFromStickyText()
}

Expand Down
Loading