feat(app): a card without saved settings imports with its camera's profile

BRIEF §13 camera profiles: the settings saved last by another card of the same
camera model; a card seen for the first time takes them once its first plan
names the camera. Remembered cards without settings start from the archive's
templates.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012iLMBNwBE2GnphAsu4cjaC
This commit is contained in:
Claude committed 2026-10-02 22:35:00 +00:00
1 parent 55469ae086
commit 758bcb162f
3 files changed
+65 -3

No files matched your search

@@ -1,5 +1,8 @@
using System.Text.Json;
using System.Text.Json.Serialization;
using Titano.App.Import;
using Titano.Core.Import;
using Titano.Core.Model;
using Titano.Data.Archiving;
using Titano.Testing;
@@ -66,4 +69,30 @@ public sealed class ImportChoicesTests
Assert.False(a.TitlesChangeNames);
Assert.True((a with { FolderTemplate = "{year}/{Title:upper}" }).TitlesChangeNames);
}
[Test]
public void ACardWithoutSettingsTakesTheLastSavedProfileOfItsCamera()
{
var older = Card("Canon", "Canon EOS R5", new CardProfile { SessionGapMinutes = 20 }, daysAgo: 30);
var newer = Card("Canon", "Canon EOS R5", new CardProfile { SessionGapMinutes = 90 }, daysAgo: 2);
var other = Card("SONY", "ILCE-7M4", new CardProfile { SessionGapMinutes = 5 }, daysAgo: 1);
var unsaved = Card("Canon", "Canon EOS R5", null, daysAgo: 0);
Assert.Equal(90, CameraProfiles.Find("Canon", "Canon EOS R5", [older, newer, other, unsaved])!.SessionGapMinutes);
Assert.Null(CameraProfiles.Find("Canon", "Canon EOS R6", [older, newer, other]));
Assert.Null(CameraProfiles.Find("Canon", null, [older, newer]));
Assert.Null(CameraProfiles.Find("Canon", "Canon EOS R5", [unsaved]), "only saved settings are shared");
}
private static MediaCard Card(string make, string model, CardProfile? profile, int daysAgo) => new()
{
Id = Guid.CreateVersion7(),
Identity = Guid.NewGuid().ToString("N"),
CameraMake = make,
CameraModel = model,
ProfileJson = profile is null ? null : JsonSerializer.Serialize(profile, StoredProfile),
LastSeen = DateTimeOffset.UtcNow.AddDays(-daysAgo),
};
/// <summary>How the card repository stores a profile (camel case, enum names).</summary>
private static readonly JsonSerializerOptions StoredProfile = new() { PropertyNamingPolicy = JsonNamingPolicy.CamelCase, Converters = { new JsonStringEnumConverter() } };
}