Skip to content

Commit 228098b

Browse files
committed
Fix bug in Closing command that caused incorrect list order due to abandoned changes
1 parent 6d4ba28 commit 228098b

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

IPConfig/ViewModels/IPConfigListViewModel.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,8 @@ where match.Success
419419

420420
int order = FileOrderHelper.GetOrder(orders);
421421
var copy = original.DeepClone();
422+
// Order 属性被标记为 [JsonIgnore],需要手动赋值。
423+
copy.Order = original.Order;
422424
copy.Name = $"{Lang.Copy_Noun}{order}-{original.Name}";
423425
copy.BeginEdit();
424426
InsertNewIPConfig(copy);

IPConfig/ViewModels/MainViewModel.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,14 @@ private void Closing(CancelEventArgs e)
267267
}
268268
else if (result == MessageBoxResult.No)
269269
{
270-
Messenger.Send<CollectionChangeActionMessage<EditableIPConfigModel>>(new(this, CollectionChangeAction.Remove, item));
270+
if (item.Order < 0)
271+
{
272+
Messenger.Send<CollectionChangeActionMessage<EditableIPConfigModel>>(new(this, CollectionChangeAction.Remove, item));
273+
}
274+
else
275+
{
276+
item.RejectChanges();
277+
}
271278

272279
continue;
273280
}

0 commit comments

Comments
 (0)