Skip to content

Commit c56374d

Browse files
lukstbitdavid-allison
authored andcommitted
Use ntid instead of nid in ManageNoteTypesViewModel
1 parent 7c11d01 commit c56374d

1 file changed

Lines changed: 13 additions & 13 deletions

File tree

AnkiDroid/src/main/java/com/ichi2/anki/notetype/ManageNoteTypesViewModel.kt

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -82,18 +82,18 @@ class ManageNoteTypesViewModel : ViewModel() {
8282
}
8383

8484
fun rename(
85-
nid: NoteTypeId,
85+
ntid: NoteTypeId,
8686
name: String,
8787
) {
88-
Timber.i("Renaming notetype with id $nid")
88+
Timber.i("Renaming notetype with id $ntid")
8989
_state.update { oldState -> oldState.copy(isLoading = true) }
9090
viewModelScope.launch {
9191
undoableOp<OpChanges> {
92-
safeRenameNoteType(nid, name)
92+
safeRenameNoteType(ntid, name)
9393
.onSuccess { changes ->
9494
_state.update { oldState ->
9595
val updatedNoteTypes =
96-
oldState.noteTypes.withUpdatedItem(nid) { old -> old.copy(name = name) }
96+
oldState.noteTypes.withUpdatedItem(ntid) { old -> old.copy(name = name) }
9797
oldState.copy(isLoading = false, noteTypes = updatedNoteTypes)
9898
}
9999
return@undoableOp changes
@@ -114,9 +114,9 @@ class ManageNoteTypesViewModel : ViewModel() {
114114
}
115115
}
116116

117-
/** Deletes the note type with [nid] and also updates the multi select mode status if needed */
118-
fun delete(nid: NoteTypeId) {
119-
Timber.i("Deleting notetype with id $nid")
117+
/** Deletes the note type with [ntid] and also updates the multi select mode status if needed */
118+
fun delete(ntid: NoteTypeId) {
119+
Timber.i("Deleting notetype with id $ntid")
120120
_state.update { oldState -> oldState.copy(isLoading = true) }
121121
val noteTypesCount = _state.value.noteTypes.size
122122
viewModelScope.launch {
@@ -127,10 +127,10 @@ class ManageNoteTypesViewModel : ViewModel() {
127127
}
128128
return@undoableOp OpChanges.getDefaultInstance()
129129
}
130-
safeRemoveNoteType(nid)
130+
safeRemoveNoteType(ntid)
131131
.onSuccess { changes ->
132132
_state.update { oldState ->
133-
val updatedNoteTypes = oldState.noteTypes.filterNot { it.id == nid }
133+
val updatedNoteTypes = oldState.noteTypes.filterNot { it.id == ntid }
134134
oldState.copy(
135135
isLoading = false,
136136
noteTypes = updatedNoteTypes,
@@ -322,20 +322,20 @@ val ManageNoteTypesViewModel.selectedNoteTypes: List<NoteTypeItemState>
322322
get() = state.value.noteTypes.filter { it.isSelected }
323323

324324
private fun Collection.safeRenameNoteType(
325-
nid: NoteTypeId,
325+
ntid: NoteTypeId,
326326
newName: String,
327327
): Result<OpChanges> =
328328
try {
329-
val currentNoteType: Notetype = getNotetype(nid)
329+
val currentNoteType: Notetype = getNotetype(ntid)
330330
val renamedNotetype = currentNoteType.copy { this.name = newName }
331331
Result.success(updateNotetype(renamedNotetype))
332332
} catch (exception: Exception) {
333333
Result.failure(exception)
334334
}
335335

336-
private fun Collection.safeRemoveNoteType(nid: NoteTypeId): Result<OpChanges> =
336+
private fun Collection.safeRemoveNoteType(ntid: NoteTypeId): Result<OpChanges> =
337337
try {
338-
Result.success(removeNotetype(nid))
338+
Result.success(removeNotetype(ntid))
339339
} catch (exception: Exception) {
340340
Result.failure(exception)
341341
}

0 commit comments

Comments
 (0)