fix(project): a hero chosen later outranks one still waiting for its photo
TranslateFramePositions read the stored pending frames, then parked the project's own hero when the receiving copy lacked its photo (leaving no hero chosen), and only then placed pending entries: a stale pending hero whose photo the copy held became the hero again and the newer choice was lost. When a hero is chosen, stored pending entries no longer carry the hero flag (an entry left with nothing to place goes) before positions are translated, so only the hero parked now may wait. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012iLMBNwBE2GnphAsu4cjaC
This commit is contained in:
2 files changed
+53
-3
No files matched your search
@@ -245,6 +245,44 @@ public sealed class ProjectSettingsTests
|
||||
Assert.Null(placed.PendingFrames);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void AHeroChosenSinceAnotherWaitedStaysTheHeroWhenItMustWaitToo()
|
||||
{
|
||||
// This PC chose photo 3 as the hero before the server had it, so it waits there; an editor on the server then
|
||||
// chose photo 2, which this PC lacks.
|
||||
var photos = Enumerable.Range(0, 4).Select(Photo).ToList();
|
||||
var server = Frames(photos[..3]);
|
||||
var here = Frames([photos[0], photos[1], photos[3]]);
|
||||
var edited = new ProjectSettings
|
||||
{
|
||||
ExcludedFrames = [0],
|
||||
HeroFrame = 2,
|
||||
PendingFrames = [new PendingFrame { Sha256 = photos[3].Sha256, Size = photos[3].Size, CapturedAt = photos[3].CapturedAt, Hero = true }],
|
||||
};
|
||||
|
||||
var taken = ProjectSettings.FromJson(Assert.NotNull(ProjectSettings.TranslateFramePositions(edited.ToJson(), server, here)));
|
||||
|
||||
Assert.Null(taken.HeroFrame);
|
||||
Assert.SequenceEqual([0], taken.ExcludedFrames);
|
||||
var waiting = Assert.NotNull(taken.PendingFrames);
|
||||
Assert.Count(1, waiting);
|
||||
Assert.True(waiting[0].Hero && waiting[0].Sha256 == photos[2].Sha256, "the newer hero waits for its photo");
|
||||
Assert.True(taken.HeroPending);
|
||||
|
||||
// Its photo arrives: it is the hero again.
|
||||
var arrived = Frames([photos[0], photos[1], photos[2], photos[3]]);
|
||||
var moved = ProjectSettings.MoveFramePositions(taken.ToJson(), new Dictionary<int, int> { [2] = 3 }) ?? taken.ToJson();
|
||||
var placed = ProjectSettings.FromJson(Assert.NotNull(ProjectSettings.TranslateFramePositions(moved, null, arrived)));
|
||||
Assert.Equal(2, placed.HeroFrame);
|
||||
Assert.Null(placed.PendingFrames);
|
||||
|
||||
// A hero chosen here while one waits clears the waiting one, even before its photo arrives.
|
||||
var chosen = (taken with { HeroFrame = 1 }).ToJson();
|
||||
var cleared = ProjectSettings.FromJson(Assert.NotNull(ProjectSettings.TranslateFramePositions(chosen, null, here)));
|
||||
Assert.Equal(1, cleared.HeroFrame);
|
||||
Assert.Null(cleared.PendingFrames);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void AProjectNamingNoFrameCrossesAsItIs()
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user