Fix notetype conflict resolution (#2967)

* Fix undoing notetype conflict resolution

* Fix field/template mapping after notetype conflict resolution
This commit is contained in:
RumovZ 2024-01-29 04:00:57 +01:00 committed by GitHub
parent 5849fc6f64
commit 69a51ec296
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -361,7 +361,7 @@ impl<'n> NoteContext<'n> {
for ((existing_ntid, incoming_ntid), note_ids) in
notetype_conflicts(incoming_notes, existing_guids)
{
let mut existing = self
let original_existing = self
.target_col
.storage
.get_notetype(existing_ntid)?
@ -372,10 +372,11 @@ impl<'n> NoteContext<'n> {
.get_notetype(incoming_ntid)?
.or_not_found(incoming_ntid)?;
if existing.is_cloze() != incoming.is_cloze() {
if original_existing.is_cloze() != incoming.is_cloze() {
return Err(ImportError::NotetypeKindMergeConflict.into());
}
let mut existing = original_existing.clone();
existing.merge(&incoming);
incoming.merge(&existing);
self.record_remapped_ords(&incoming);
@ -383,7 +384,8 @@ impl<'n> NoteContext<'n> {
let old_notetype_name = existing.name.clone();
let new_fields = existing.field_ords_vec();
let new_templates = Some(existing.template_ords_vec());
self.update_notetype(&mut incoming, existing, true)?;
incoming.copy_ords(&existing);
self.update_notetype(&mut incoming, original_existing, true)?;
self.target_col
.change_notetype_of_notes_inner(ChangeNotetypeInput {