fix(board): skip the refresh when the card editor wrote nothing

Every editor close rebuilt all columns, so opening a card and cancelling
reset each column's scroll position. The editor now reports whether it
saved the card or created a tag in the nested picker, and the board only
refreshes in that case.
This commit is contained in:
doyaGu committed 2026-10-03 22:46:09 -04:00
1 parent a2c4e1853d
commit 253847323a
5 files changed
+91 -6

No files matched your search

@@ -204,6 +204,66 @@ public class BoardViewModelTests
Assert.AreEqual(card.Id, board.Columns[0].Cards.Single().Card.Id);
}
[TestMethod]
public async Task EditorThatWroteNothingLeavesTheColumnsAlone()
{
using var fixture = new Fixture();
ColumnModel column = fixture.Repository.AddColumn("A", "");
fixture.Repository.AddCard(column.Id, "t", "", []);
BoardViewModel board = fixture.CreateBoard();
ColumnViewModel shown = board.Columns.Single();
int writes = 0;
board.DataWritten += (_, _) => writes++;
// Cancel a new card, confirm an unchanged existing card, confirm an empty new card.
fixture.Dialogs.Script = dialog => dialog is CardEditorDialogViewModel editor
? editor.RequestCancelAsync()
: Task.CompletedTask;
await shown.AddCardCommand.ExecuteAsync(null);
fixture.Dialogs.Script = dialog =>
{
(dialog as CardEditorDialogViewModel)?.ConfirmCommand.Execute(null);
return Task.CompletedTask;
};
await shown.Cards.Single().EditCommand.ExecuteAsync(null);
await shown.AddCardCommand.ExecuteAsync(null);
Assert.AreSame(shown, board.Columns.Single());
Assert.AreEqual(0, writes);
}
[TestMethod]
public async Task TagCreatedInACancelledEditRefreshesTheBoard()
{
using var fixture = new Fixture();
fixture.Repository.AddColumn("A", "");
BoardViewModel board = fixture.CreateBoard();
ColumnViewModel shown = board.Columns.Single();
int writes = 0;
board.DataWritten += (_, _) => writes++;
fixture.Dialogs.Script = async dialog =>
{
switch (dialog)
{
case CardEditorDialogViewModel editor:
await editor.AddTagCommand.ExecuteAsync(null);
editor.Tags.Clear();
await editor.RequestCancelAsync();
break;
case TagPickerDialogViewModel picker:
picker.NewName = "fresh";
picker.NewColor = "#123456";
picker.CreateCommand.Execute(null);
break;
}
};
await shown.AddCardCommand.ExecuteAsync(null);
Assert.AreNotSame(shown, board.Columns.Single());
Assert.AreEqual(1, writes);
}
[TestMethod]
public void UnchangedEditConfirmationWritesNothing()
{