Files
Chronos/src/Titano.Data/Processing/HeroFrame.cs
T
Claude afaa387daf feat(server): settings sent alone move the hero frame with the project's hero
The sync of a local copy sends only the project; the server now maps its hero
index to the frame the Library shows, through the same helper the archive
engine's project writes use. Edits that name the hero are audited as such.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012iLMBNwBE2GnphAsu4cjaC
2026-10-03 16:37:33 +00:00

27 lines
1.2 KiB
C#

using Titano.Core.Model;
using Titano.Core.Project;
using Titano.Data.Repositories;
namespace Titano.Data.Processing;
/// <summary>
/// The index's hero frame (<see cref="Sequence.HeroFrameId"/>, the frame the Library shows) follows the project's hero
/// (<see cref="ProjectSettings.HeroFrame"/>, a frame index; frame indices are positions).
/// </summary>
public static class HeroFrame
{
/// <summary>
/// The <see cref="SequenceEdit.HeroFrameId"/> of a project whose hero went from <paramref name="before"/> to
/// <paramref name="after"/>: null when it did not change, else the frame at the new index, or <see cref="Guid.Empty"/>
/// (the first frame shows) when there is none.
/// </summary>
public static async Task<Guid?> EditAsync(TitanoDatabase db, Guid sequenceId, int? before, int? after, CancellationToken cancellationToken)
{
ArgumentNullException.ThrowIfNull(db);
if (before == after) return null;
if (after is not >= 0) return Guid.Empty;
var frames = await db.Frames.ListBySequenceAsync(sequenceId, after.Value - 1, 1, cancellationToken).ConfigureAwait(false);
return frames is [{ } frame] && frame.Index == after ? frame.Id : Guid.Empty;
}
}