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

+17
View File
@@ -1,4 +1,5 @@
using Titano.Core.Import;
using Titano.Core.Model;
using Titano.Core.Naming;
using Titano.Data.Archiving;
@@ -92,3 +93,19 @@ public sealed record ImportChoices
private static bool UsesTitle(string template) => template.Contains("{title", StringComparison.OrdinalIgnoreCase);
}
/// <summary>
/// Camera profiles (BRIEF §13): a card without saved settings imports with the settings saved last by another card
/// of the same camera model, so a new card for a known camera needs no setup.
/// </summary>
public static class CameraProfiles
{
public static CardProfile? Find(string? make, string? model, IEnumerable<MediaCard> cards) =>
model is null
? null
: cards.Where(c => c.ProfileJson is { Length: > 0 } && string.Equals(c.CameraModel, model, StringComparison.Ordinal)
&& string.Equals(c.CameraMake, make, StringComparison.Ordinal))
.MaxBy(c => c.LastSeen) is { } source
? ImportService.ProfileOf(source)
: null;
}
+19 -3
View File
@@ -81,6 +81,7 @@ public sealed class ImportViewModel : SectionViewModel
private string? _autoStartKey;
private bool _activeTemplateIsFolder;
private bool _refreshing;
private bool _profileResolved;
public ImportViewModel(ShellViewModel shell)
: base(SectionKey.Import, "Icon.Import")
@@ -552,8 +553,13 @@ public sealed class ImportViewModel : SectionViewModel
Details = null;
Result = null;
Nickname.Load(_selected?.Card?.Nickname ?? string.Empty);
var profile = _selected?.Card is { } card ? ImportService.ProfileOf(card) : DefaultProfile();
LoadChoices(profile);
var card = _selected?.Card;
// A card that has a camera but no saved settings takes the camera profile now; one seen for the first time
// takes it once its first plan names the camera (InheritedProfile).
_profileResolved = _selected?.Kind != SourceKind.Card || card is { ProfileJson.Length: > 0 } || card?.CameraModel is not null;
LoadChoices(card is { ProfileJson.Length: > 0 } ? ImportService.ProfileOf(card)
: card is not null && CameraProfiles.Find(card.CameraMake, card.CameraModel, _cards.Where(c => c.Id != card.Id)) is { } camera ? camera
: DefaultProfile());
_ = LoadIdentityAsync();
OnPropertyChanged(string.Empty);
Replan();
@@ -730,9 +736,11 @@ public sealed class ImportViewModel : SectionViewModel
if (cts.IsCancellationRequested) return;
_existingFolders = folders;
_rawPlan = plan;
if (InheritedProfile(plan) is { } camera) LoadChoices(camera);
ApplyPlan();
SetStatus(ImportPhase.Ready, null);
if (_autoStartKey is { } key && key == _selected?.Key)
// An inherited profile that groups or names differently plans again first.
if (_autoStartKey is { } key && key == _selected?.Key && !_planDelay.IsEnabled)
{
_autoStartKey = null;
if (StartBlocker is null) await StartAsync();
@@ -748,6 +756,14 @@ public sealed class ImportViewModel : SectionViewModel
}
}
/// <summary>The camera profile of a card seen for the first time, once its first plan names the camera (BRIEF §13).</summary>
private CardProfile? InheritedProfile(ImportPlan plan)
{
if (_profileResolved || _selected?.Card is not { } card) return null;
_profileResolved = true;
return plan.Sessions is [var first, ..] ? CameraProfiles.Find(first.CameraMake, first.CameraModel, _cards.Where(c => c.Id != card.Id)) : null;
}
/// <summary>The selected card's id, registering an inserted card on first sight.</summary>
private async Task<Guid?> RegisteredCardIdAsync()
{