fix(copies): close the owner review 6 verification findings
A merge could still trash photos it never verified, resume against a pair the user had answered meanwhile, and take different unhashed photos for copies; the dialog and the lists worded several facts wrongly or lost them on refresh. - Merge: a retry resumes only while the pair is still the job's; Verify requires the other archive online and its folder in place, stops on an unreadable photo, files a differing unhashed photo as a second version and must cover every frame before Trash; the plan hashes unmatched unhashed photos first, lists "Deleted in the other" and names the relinked servers; second versions stay discoverable (CopySides.VersionsAsync). - Integrate: a retry after a failure before the journal runs again. - Sync: a sequence back after a 404 stays Linked while its link holds; a local cull no longer asks for attention. - Block lines of both planners name the right sequence, archive, server and space through one formatter. - Compare dialog: one Details row per setting with worded values, Projects headings, Choose focuses the kept-sequence radios, the photo selection reaches rows outside the viewport, the Replace confirmation lists the losers per side, plan lines read as queued. - Matches and Library: counts first and grouped, integrating shown as a share, local matches name the other archive, the Library keeps its match and "deleted on server" statuses across a refresh. Refs #73 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
d10577b175
commit
b34b6b6fe0
41 files changed
+1046
-193
No files matched your search
@@ -5,23 +5,35 @@ using Chronos.Ui.Mvvm;
|
||||
namespace Chronos.App.Server.Copies;
|
||||
|
||||
/// <summary>
|
||||
/// A detail that differs (the Details part): its label, this PC's and the other side's value, and the side both take
|
||||
/// (nothing preselected: <see cref="ChoiceIndex"/> -1 until the user picks). In a merge the first column is the kept
|
||||
/// A setting that differs (the Details part): its label, this PC's and the other side's value, and the side both take
|
||||
/// (nothing preselected: <see cref="ChoiceIndex"/> -1 until the user picks). The lines of one setting (the members of an
|
||||
/// Auto parameter, the positions parked by photo) are one row and one choice. In a merge the first column is the kept
|
||||
/// sequence's: <paramref name="swapped"/> when that is the pair's other sequence (the line compares the pair's first with it).
|
||||
/// </summary>
|
||||
public sealed class CopyDetailRow(DetailLine line, bool isMerge, Action changed, bool swapped = false) : ObservableObject
|
||||
public sealed class CopyDetailRow(IReadOnlyList<DetailLine> lines, bool isMerge, Action changed, bool swapped = false) : ObservableObject
|
||||
{
|
||||
private int _choiceIndex = -1;
|
||||
|
||||
public DetailLine Line { get; } = line;
|
||||
public CopyDetailRow(DetailLine line, bool isMerge, Action changed, bool swapped = false) : this([line], isMerge, changed, swapped)
|
||||
{
|
||||
}
|
||||
|
||||
public IReadOnlyList<DetailLine> Lines { get; } = lines;
|
||||
public DetailLine Line => Lines[0];
|
||||
|
||||
/// <summary>The first line's path: the row's identity across a rebuild.</summary>
|
||||
public string Path => Line.Path;
|
||||
|
||||
/// <summary>Every path the row's choice answers.</summary>
|
||||
public IEnumerable<string> Paths => Lines.Select(l => l.Path);
|
||||
|
||||
public string Label => SyncText.DetailLabel(Line.Path);
|
||||
private string? First => swapped ? Line.There : Line.Here;
|
||||
private string? Second => swapped ? Line.Here : Line.There;
|
||||
public string HereText => Value(First);
|
||||
public string ThereText => Value(Second);
|
||||
public string HereToolTip => First ?? Loc.L("Server.Sync.None");
|
||||
public string ThereToolTip => Second ?? Loc.L("Server.Sync.None");
|
||||
private string? First(DetailLine l) => swapped ? l.There : l.Here;
|
||||
private string? Second(DetailLine l) => swapped ? l.Here : l.There;
|
||||
public string HereText => Values(First);
|
||||
public string ThereText => Values(Second);
|
||||
public string HereToolTip => Raw(First);
|
||||
public string ThereToolTip => Raw(Second);
|
||||
|
||||
public string HereWord => Loc.L(isMerge ? "Server.Copies.Detail.Kept" : "Server.Copies.Detail.ThisPc");
|
||||
public string ThereWord => Loc.L(isMerge ? "Server.Copies.Detail.Other" : "Server.Copies.Detail.Server");
|
||||
@@ -57,6 +69,11 @@ public sealed class CopyDetailRow(DetailLine line, bool isMerge, Action changed,
|
||||
OnPropertyChanged(nameof(Chosen));
|
||||
}
|
||||
|
||||
private static string Value(string? value) => string.IsNullOrWhiteSpace(value) ? Loc.L("Server.Sync.None")
|
||||
: value.Length <= 40 ? value : string.Concat(value.AsSpan(0, 39), "…");
|
||||
/// <summary>One side's values as the sync words them ("41", "on", "12 photos"), the distinct ones joined.</summary>
|
||||
private string Values(Func<DetailLine, string?> side) =>
|
||||
string.Join(Loc.Separator, Lines.Select(l => SyncText.DetailValue(l.Path, side(l))).Distinct(StringComparer.Ordinal));
|
||||
|
||||
/// <summary>One side's raw values for the tooltip.</summary>
|
||||
private string Raw(Func<DetailLine, string?> side) =>
|
||||
string.Join(Environment.NewLine, Lines.Select(l => side(l) ?? Loc.L("Server.Sync.None")));
|
||||
}
|
||||
@@ -4,6 +4,7 @@ using Chronos.App.Infrastructure;
|
||||
using Chronos.App.Settings;
|
||||
using Chronos.App.Shell;
|
||||
using Chronos.Core.Localization;
|
||||
using Chronos.Data.Archiving;
|
||||
using Chronos.Data.Copies;
|
||||
using Chronos.Data.Sync;
|
||||
using Chronos.Ui.Mvvm;
|
||||
@@ -94,12 +95,15 @@ public sealed class CopyDialogViewModel : ArchiveDialogViewModel
|
||||
public FoundCopy Copy => _pair.Copy;
|
||||
public bool IsMerge => Copy.Kind == CopyKind.LocalLocal;
|
||||
|
||||
public string Heading => Loc.L(IsMerge ? "Server.Copies.Dialog.Merge" : "Server.Copies.Dialog.Compare");
|
||||
/// <summary>"Compare: Lighthouse": the dialog names the sequence it acts on.</summary>
|
||||
public string Heading => Loc.L(IsMerge ? "Server.Copies.Dialog.MergeTitle" : "Server.Copies.Dialog.CompareTitle", Here.Title);
|
||||
|
||||
/// <summary>"This PC · Lighthouse · 1,204 photos · 18.2 GB".</summary>
|
||||
public string HereText => Loc.L("Server.Copies.Where.ThisPc", CopyText.Facts(Here));
|
||||
/// <summary>"This PC · Main archive · 1,204 photos · 18.2 GB"; with the title first when the two sides' titles differ.</summary>
|
||||
public string HereText => Loc.L("Server.Copies.Where.ThisPc", CopyText.Facts(Here, TitlesDiffer));
|
||||
|
||||
public string ThereText => IsMerge ? Loc.L("Server.Copies.Where.ThisPc", CopyText.Facts(There)) : CopyText.Facts(There);
|
||||
public string ThereText => IsMerge ? Loc.L("Server.Copies.Where.ThisPc", CopyText.Facts(There, TitlesDiffer)) : CopyText.Facts(There, TitlesDiffer);
|
||||
|
||||
private bool TitlesDiffer => !string.Equals(Here.Title, There.Title, StringComparison.CurrentCulture);
|
||||
|
||||
private CopyFacts Here => _review?.Here ?? _pair.Here;
|
||||
private CopyFacts There => _review?.There ?? _pair.There;
|
||||
@@ -123,7 +127,7 @@ public sealed class CopyDialogViewModel : ArchiveDialogViewModel
|
||||
OnPropertyChanged(nameof(IsProjects));
|
||||
OnPropertyChanged(nameof(IsPlan));
|
||||
OnPropertyChanged(nameof(ApplyToolTip));
|
||||
if (value == CopyDialogPart.Plan) SchedulePlan(TimeSpan.Zero);
|
||||
if (value == CopyDialogPart.Plan || (value == CopyDialogPart.Projects && (_plan ?? (object?)_merge) is null)) SchedulePlan(TimeSpan.Zero);
|
||||
_apply.RaiseCanExecuteChanged();
|
||||
}
|
||||
}
|
||||
@@ -296,6 +300,7 @@ public sealed class CopyDialogViewModel : ArchiveDialogViewModel
|
||||
_review = await _engine.CompareAsync(Copy.Id, Copy.Kind == CopyKind.LocalServer ? _shell.Services.Sync.Remote : null, CancellationToken.None);
|
||||
if (IsClosed) return;
|
||||
Build(_review);
|
||||
if ((_plan?.Projects ?? _merge?.Projects) is { } steps) SetProjectTargets(steps);
|
||||
IsLoaded = true;
|
||||
if (_integrate && _part == CopyDialogPart.Plan && Unchosen > 0) _part = CopyDialogPart.Details;
|
||||
OnAllPropertiesChanged();
|
||||
@@ -354,7 +359,8 @@ public sealed class CopyDialogViewModel : ArchiveDialogViewModel
|
||||
private void BuildDetails(CopyReview review)
|
||||
{
|
||||
var chosen = _details.GroupBy(d => d.Path, StringComparer.Ordinal).ToDictionary(g => g.Key, g => g.First().ChoiceIndex, StringComparer.Ordinal);
|
||||
Details = [.. review.Details.Select(line => new CopyDetailRow(line, IsMerge, Changed, Swapped))];
|
||||
Details = [.. review.Details.GroupBy(line => SyncText.DetailSetting(line.Path), StringComparer.Ordinal)
|
||||
.Select(setting => new CopyDetailRow([.. setting], IsMerge, Changed, Swapped))];
|
||||
foreach (var row in _details) row.SetQuietly(chosen.GetValueOrDefault(row.Path, -1));
|
||||
}
|
||||
|
||||
@@ -478,7 +484,8 @@ public sealed class CopyDialogViewModel : ArchiveDialogViewModel
|
||||
}
|
||||
|
||||
private Dictionary<string, CopySide> DetailChoices() =>
|
||||
_details.Where(d => d.Chosen is not null).ToDictionary(d => d.Path, d => d.Chosen!.Value, StringComparer.Ordinal);
|
||||
_details.Where(d => d.Chosen is not null).SelectMany(d => d.Paths.Select(p => (Path: p, Side: d.Chosen!.Value)))
|
||||
.DistinctBy(c => c.Path, StringComparer.Ordinal).ToDictionary(c => c.Path, c => c.Side, StringComparer.Ordinal);
|
||||
|
||||
private async Task PlanAsync(CancellationToken ct)
|
||||
{
|
||||
@@ -526,6 +533,17 @@ public sealed class CopyDialogViewModel : ArchiveDialogViewModel
|
||||
}
|
||||
}
|
||||
|
||||
private string TitleOf(Guid sequenceId) => sequenceId == Copy.LocalId ? Here.Title : There.Title;
|
||||
|
||||
/// <summary>Choose on "Choose the sequence to keep": the view moves the keyboard focus to the Kept sequence radios.</summary>
|
||||
public event EventHandler? KeepFocusRequested;
|
||||
|
||||
private void RequestKeepFocus()
|
||||
{
|
||||
Part = CopyDialogPart.Plan;
|
||||
KeepFocusRequested?.Invoke(this, EventArgs.Empty);
|
||||
}
|
||||
|
||||
private CopyFacts? KeptFacts => _keepId is { } keep ? keep == Copy.LocalId ? Here : There : null;
|
||||
private CopyFacts? DroppedFacts => _keepId is { } keep ? keep == Copy.LocalId ? There : Here : null;
|
||||
|
||||
@@ -544,7 +562,11 @@ public sealed class CopyDialogViewModel : ArchiveDialogViewModel
|
||||
Trash(plan.Photos, PhotoAction.TrashThere, there);
|
||||
var versions = plan.Photos.Count(p => p.Action == PhotoAction.SendVersion);
|
||||
if (versions > 0) there.Add(new(Loc.Plural("Server.Copies.Plan.ServerUsesOurs", versions, ServerName), Loc.L("Tooltips.Server.Copies.Plan.ServerUsesOurs")));
|
||||
if (plan.DetailChanges > 0) here.Add(new(Loc.Plural("Server.Copies.Plan.Details", plan.DetailChanges)));
|
||||
// A detail changes on the side that does not keep its own value: this PC takes the server's, the server this PC's.
|
||||
var toHere = _details.Where(d => d.Chosen == CopySide.Other).SelectMany(d => d.Paths).Distinct(StringComparer.Ordinal).Count();
|
||||
var toThere = _details.Where(d => d.Chosen == CopySide.ThisPc).SelectMany(d => d.Paths).Distinct(StringComparer.Ordinal).Count();
|
||||
if (toHere > 0) here.Add(new(Loc.Plural("Server.Copies.Plan.Details", toHere)));
|
||||
if (toThere > 0) there.Add(new(Loc.Plural("Server.Copies.Plan.Details", toThere)));
|
||||
var fromHere = plan.Projects.Count(p => p.From == CopySide.ThisPc);
|
||||
var fromThere = plan.Projects.Count - fromHere;
|
||||
if (fromThere > 0) here.Add(new(Loc.Plural("Server.Copies.Plan.Projects", fromThere)));
|
||||
@@ -552,8 +574,7 @@ public sealed class CopyDialogViewModel : ArchiveDialogViewModel
|
||||
here.Add(new(Loc.L("Server.Copies.Plan.Free", Formatting.Bytes(plan.FreeBytes)), Loc.L("Tooltips.Server.Copies.Plan.Free")));
|
||||
if (plan.QuotaLeftBytes is { } quota) there.Add(new(Loc.L("Server.Copies.Plan.Quota", Formatting.Bytes(quota)), Loc.L("Tooltips.Server.Copies.Plan.Quota")));
|
||||
if (plan.LeftOut > 0) here.Add(new(Loc.Plural("Server.Copies.Plan.LeftOut", plan.LeftOut), Loc.L("Tooltips.Server.Copies.Plan.LeftOut")));
|
||||
foreach (var row in _hereProjects.Concat(_thereProjects))
|
||||
row.SetTarget(plan.Projects.FirstOrDefault(p => p.SourceProjectId == row.Project.Id)?.TargetName);
|
||||
SetProjectTargets(plan.Projects);
|
||||
blocks.AddRange(plan.Blocks.Select(Block));
|
||||
}
|
||||
else if (_merge is { } merge)
|
||||
@@ -563,10 +584,14 @@ public sealed class CopyDialogViewModel : ArchiveDialogViewModel
|
||||
if (merge.DetailChanges > 0) here.Add(new(Loc.Plural("Server.Copies.Plan.Details", merge.DetailChanges)));
|
||||
if (merge.Renders.Count > 0) here.Add(new(Loc.Plural("Server.Copies.Plan.Renders", merge.Renders.Count)));
|
||||
if (merge.Projects.Count > 0) here.Add(new(Loc.Plural("Server.Copies.Plan.Projects", merge.Projects.Count)));
|
||||
SetProjectTargets(merge.Projects);
|
||||
if (merge.SessionKeys.Count > 0)
|
||||
here.Add(new(Loc.L("Server.Copies.Plan.SessionKeys", Formatting.Count(merge.SessionKeys.Count)),
|
||||
string.Join(Environment.NewLine, [Loc.L("Tooltips.Server.Copies.Plan.SessionKeys"), .. merge.SkippedSessionKeys])));
|
||||
foreach (var link in merge.Links) here.Add(new(Loc.L("Server.Copies.Plan.Relink", link), Loc.L("Tooltips.Server.Copies.Plan.Relink")));
|
||||
if (merge.DeletedInOther > 0)
|
||||
here.Add(new(Loc.Plural("Server.Copies.Plan.DeletedInOther", merge.DeletedInOther), Loc.L("Tooltips.Server.Copies.Plan.DeletedInOther")));
|
||||
foreach (var link in merge.LinkNames.Count == merge.Links.Count ? merge.LinkNames : merge.Links)
|
||||
here.Add(new(Loc.L("Server.Copies.Plan.Relink", link), Loc.L("Tooltips.Server.Copies.Plan.Relink")));
|
||||
here.Add(new(Loc.L("Server.Copies.Plan.Free", Formatting.Bytes(merge.FreeBytes)), Loc.L("Tooltips.Server.Copies.Plan.Free")));
|
||||
if (DroppedFacts is { } dropped)
|
||||
there.Add(new(Loc.Plural("Server.Copies.Plan.DropToTrash", dropped.Photos, Formatting.Bytes(dropped.Bytes)), IsWarning: true));
|
||||
@@ -604,14 +629,24 @@ public sealed class CopyDialogViewModel : ArchiveDialogViewModel
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Each project row names the project it becomes at the other home (the plan's free name).</summary>
|
||||
private void SetProjectTargets(IReadOnlyList<ProjectStep> steps)
|
||||
{
|
||||
foreach (var row in _hereProjects.Concat(_thereProjects))
|
||||
row.SetTarget(steps.FirstOrDefault(p => p.SourceProjectId == row.Project.Id)?.TargetName);
|
||||
}
|
||||
|
||||
private CopyBlockLine Block(CopyBlock block)
|
||||
{
|
||||
var need = _plan is { } plan ? Formatting.Bytes(plan.FetchBytes) : _merge is { } merge ? Formatting.Bytes(merge.CopyBytes) : null;
|
||||
var text = CopyText.Block(block, Here.Title, ServerName, need, Unchosen);
|
||||
// The sentences the job would fail with: one formatter for both (the kept and the other sequence of a merge by title).
|
||||
var text = _merge is { } merge && IsMerge
|
||||
? SequenceMerger.BlockText(merge, block, TitleOf(merge.KeepId), TitleOf(merge.KeepId == Copy.LocalId ? Copy.OtherId ?? Guid.Empty : Copy.LocalId), Unchosen)
|
||||
: _plan is { } plan ? IntegratePlanner.BlockText(plan, block, Here.Title, plan.Context?.ServerName ?? ServerName, Unchosen)
|
||||
: CopyText.Block(block, Here.Title, ServerName, null, Unchosen);
|
||||
Action? choose = block switch
|
||||
{
|
||||
CopyBlock.DetailsUnchosen => () => Part = CopyDialogPart.Details,
|
||||
CopyBlock.KeptUnchosen => () => Part = CopyDialogPart.Plan,
|
||||
CopyBlock.KeptUnchosen => RequestKeepFocus,
|
||||
_ => null,
|
||||
};
|
||||
return new CopyBlockLine(block, text, choose);
|
||||
@@ -630,7 +665,7 @@ public sealed class CopyDialogViewModel : ArchiveDialogViewModel
|
||||
{
|
||||
if (_plan is { CanApply: true } plan)
|
||||
{
|
||||
if (plan.Destructive && !_shell.Services.Dialogs.Confirm(ReplaceRequest(plan))) return;
|
||||
if (plan.Destructive && !_shell.Services.Dialogs.Confirm(ReplaceRequest(plan, plan.Context?.ServerName ?? ServerName))) return;
|
||||
IsBusy = true;
|
||||
await _engine.EnqueueIntegrateAsync(jobs, plan, CancellationToken.None);
|
||||
}
|
||||
@@ -773,15 +808,19 @@ public sealed class CopyDialogViewModel : ArchiveDialogViewModel
|
||||
await LoadAsync();
|
||||
}
|
||||
|
||||
/// <summary>"Replace photos?" (design §8.5): the losing versions per side, the last copies named first.</summary>
|
||||
internal static ConfirmRequest ReplaceRequest(IntegratePlan plan)
|
||||
/// <summary>
|
||||
/// "Replace photos?" (design §8.5): the losing versions under the side that loses them ("On this PC", "On Studio NAS"),
|
||||
/// each side's last copies named first, every photo once.
|
||||
/// </summary>
|
||||
internal static ConfirmRequest ReplaceRequest(IntegratePlan plan, string? server = null)
|
||||
{
|
||||
var trashed = plan.Photos.Where(p => p.Action is PhotoAction.TrashHere or PhotoAction.TrashThere).ToList();
|
||||
var name = server ?? plan.Context?.ServerName ?? string.Empty;
|
||||
return new ConfirmRequest
|
||||
{
|
||||
Heading = Loc.L("Server.Copies.Confirm.Replace.Title"),
|
||||
Message = Loc.Plural("Server.Copies.Confirm.Replace.Message", trashed.Count),
|
||||
Detail = Lines(plan.LastCopies, trashed.Select(p => p.FileName)),
|
||||
Detail = ReplaceLines(plan.LastCopies, trashed, name),
|
||||
SafeText = Loc.L("Archive.Dialog.Cancel"),
|
||||
SafeToolTip = Loc.L("Tooltips.Server.Copies.Confirm.Safe"),
|
||||
ActionText = Loc.L("Server.Copies.Action.IntegrateNow"),
|
||||
@@ -829,6 +868,36 @@ public sealed class CopyDialogViewModel : ArchiveDialogViewModel
|
||||
IsDestructive = true,
|
||||
};
|
||||
|
||||
/// <summary>The Replace confirmation's list: per side a heading, its last copies, then its other losing versions; ten names in all at most.</summary>
|
||||
internal static string ReplaceLines(IReadOnlyList<LastCopy> lasts, IReadOnlyList<PhotoStep> trashed, string server)
|
||||
{
|
||||
const int Listed = 10;
|
||||
var lines = new List<string>();
|
||||
var named = 0;
|
||||
var total = 0;
|
||||
foreach (var (side, action, heading) in new[]
|
||||
{
|
||||
(CopySide.ThisPc, PhotoAction.TrashHere, Loc.L("Server.Copies.Plan.OnThisPc")),
|
||||
(CopySide.Other, PhotoAction.TrashThere, Loc.L("Server.Copies.Plan.OnServer", server)),
|
||||
})
|
||||
{
|
||||
var last = lasts.Where(l => l.Side == side).ToList();
|
||||
var lastKeys = last.Select(l => l.Key).ToHashSet(StringComparer.Ordinal);
|
||||
var names = last.Select(l => Loc.L("Server.Copies.Confirm.LastCopy", l.FileName))
|
||||
.Concat(trashed.Where(p => p.Action == action && !lastKeys.Contains(p.Key)).Select(p => p.FileName))
|
||||
.Distinct(StringComparer.Ordinal).ToList();
|
||||
total += names.Count;
|
||||
if (names.Count == 0) continue;
|
||||
var room = Listed - named;
|
||||
if (room <= 0) continue;
|
||||
lines.Add(heading);
|
||||
lines.AddRange(names.Take(room).Select(n => " " + n));
|
||||
named += Math.Min(room, names.Count);
|
||||
}
|
||||
if (total > named) lines.Add(Loc.Plural("Archive.Delete.More", total - named));
|
||||
return string.Join(Environment.NewLine, lines);
|
||||
}
|
||||
|
||||
private static string Lines(IReadOnlyList<LastCopy> lasts, IEnumerable<string> rest)
|
||||
{
|
||||
const int Listed = 10;
|
||||
|
||||
@@ -107,6 +107,7 @@
|
||||
Visibility="{Binding CanDeleteThere, Converter={StaticResource CopyBoolToVisibility}}" />
|
||||
</WrapPanel>
|
||||
<ListBox Grid.Row="1" Grid.Column="1" ItemsSource="{Binding Photos}" ItemContainerStyle="{StaticResource ListBoxItem.CopyPhoto}" SelectionMode="Extended"
|
||||
infra:ListSelection.SyncsRows="True"
|
||||
VirtualizingPanel.IsVirtualizing="True" VirtualizingPanel.VirtualizationMode="Recycling" VirtualizingPanel.ScrollUnit="Pixel"
|
||||
ScrollViewer.HorizontalScrollBarVisibility="Disabled" KeyboardNavigation.TabNavigation="Continue"
|
||||
AutomationProperties.Name="{Binding SelectedClass.Text}" Visibility="{Binding HasPhotos, Converter={StaticResource CopyBoolToVisibility}}">
|
||||
@@ -128,7 +129,7 @@
|
||||
<TextBlock Grid.Column="3" Text="{Binding SizeText}" VerticalAlignment="Center" TextAlignment="Right" Typography.NumeralAlignment="Tabular" FontSize="12" />
|
||||
<TextBlock Grid.Column="4" Text="{Binding SideText}" VerticalAlignment="Center" Foreground="{DynamicResource Brush.TextMuted}" Margin="10,0,0,0"
|
||||
TextTrimming="CharacterEllipsis" FontSize="12" />
|
||||
<ComboBox Grid.Column="5" Width="120" ItemsSource="{Binding Choices}" SelectedItem="{Binding Choice}" DisplayMemberPath="Label"
|
||||
<ComboBox Grid.Column="5" Width="150" ItemsSource="{Binding Choices}" SelectedItem="{Binding Choice}" DisplayMemberPath="Label"
|
||||
ItemContainerStyle="{StaticResource ComboBoxItem.Option}" ToolTip="{l:Loc Tooltips.Server.Copies.Version}"
|
||||
AutomationProperties.Name="{Binding ChoiceAccessibleName}" Visibility="{Binding CanChoose, Converter={StaticResource CopyBoolToVisibility}}" />
|
||||
<Button Grid.Column="5" Style="{StaticResource Button.Row}" Content="{l:Loc Server.Copies.Action.Drop}" Command="{Binding DropCommand}"
|
||||
@@ -187,6 +188,7 @@
|
||||
<!-- Projects: Copy across or Leave them; each side's projects, and where each goes. -->
|
||||
<Grid Visibility="{Binding IsProjects, Converter={StaticResource CopyBoolToVisibility}}">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="*" />
|
||||
@@ -202,7 +204,10 @@
|
||||
</v:SegmentedControl>
|
||||
<TextBlock Grid.Row="1" Grid.ColumnSpan="2" Text="{Binding ProjectsNote}" Foreground="{DynamicResource Brush.TextMuted}" Margin="0,0,0,8"
|
||||
Visibility="{Binding ProjectsNote, Converter={x:Static ui:NullToCollapsedConverter.Instance}}" />
|
||||
<ItemsControl Grid.Row="2" ItemsSource="{Binding HereProjects}" Focusable="False" Margin="0,0,14,0">
|
||||
<!-- Each column says whose projects it lists (this PC or the kept sequence, the server or the other one). -->
|
||||
<TextBlock Grid.Row="2" Text="{Binding HereHeading}" FontWeight="SemiBold" Margin="0,0,14,6" TextTrimming="CharacterEllipsis" ToolTip="{Binding HereHeading}" />
|
||||
<TextBlock Grid.Row="2" Grid.Column="1" Text="{Binding ThereHeading}" FontWeight="SemiBold" Margin="0,0,0,6" TextTrimming="CharacterEllipsis" ToolTip="{Binding ThereHeading}" />
|
||||
<ItemsControl Grid.Row="3" ItemsSource="{Binding HereProjects}" Focusable="False" Margin="0,0,14,0">
|
||||
<ItemsControl.ItemTemplate>
|
||||
<DataTemplate DataType="{x:Type cp:CopyProjectRow}">
|
||||
<StackPanel Orientation="Horizontal" Margin="0,0,0,6" ToolTip="{Binding ToolTip}">
|
||||
@@ -214,7 +219,7 @@
|
||||
</DataTemplate>
|
||||
</ItemsControl.ItemTemplate>
|
||||
</ItemsControl>
|
||||
<ItemsControl Grid.Row="2" Grid.Column="1" ItemsSource="{Binding ThereProjects}" Focusable="False">
|
||||
<ItemsControl Grid.Row="3" Grid.Column="1" ItemsSource="{Binding ThereProjects}" Focusable="False">
|
||||
<ItemsControl.ItemTemplate>
|
||||
<DataTemplate DataType="{x:Type cp:CopyProjectRow}">
|
||||
<StackPanel Orientation="Horizontal" Margin="0,0,0,6" ToolTip="{Binding ToolTip}">
|
||||
|
||||
@@ -141,6 +141,14 @@ public sealed class CopyListViewModel : ObservableObject, IDisposable
|
||||
.Select(p => p.Copy)
|
||||
.FirstOrDefault();
|
||||
|
||||
/// <summary>Where the other sequence of <see cref="PairOf"/>'s pair lies ("Old archive"), seen from <paramref name="sequenceId"/>.</summary>
|
||||
public string? OtherWhere(Guid sequenceId)
|
||||
{
|
||||
var id = PairOf(sequenceId)?.Id;
|
||||
if (_pairs.FirstOrDefault(p => p.Copy.Id == id) is not { } pair) return null;
|
||||
return pair.Copy.Kind == CopyKind.LocalLocal && pair.Copy.OtherId == sequenceId ? pair.Here.Where : pair.There.Where;
|
||||
}
|
||||
|
||||
/// <summary>Reads the pairs again; requests made while a pass runs share the next one.</summary>
|
||||
public async Task ReloadAsync()
|
||||
{
|
||||
@@ -219,18 +227,26 @@ public sealed class CopyListViewModel : ObservableObject, IDisposable
|
||||
/// <summary>The Library's cards and rows of local sequences in pairs that ask for a choice take "Also elsewhere" or "Deleted there".</summary>
|
||||
private void UpdateLibrary()
|
||||
{
|
||||
foreach (var item in _shell.Library.Items)
|
||||
{
|
||||
var pair = _pairs.FirstOrDefault(p => p.Copy.NeedsAttention && (p.Copy.LocalId == item.Id || p.Copy.OtherId == item.Id));
|
||||
item.SetMatch(pair is null ? null : LibraryStatus(pair, item.Id));
|
||||
}
|
||||
foreach (var item in _shell.Library.Items) item.SetMatch(StatusOf(item.Id));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The Library status of the card <paramref name="id"/> (a local sequence, or a server sequence of a pair): the status of
|
||||
/// the first pair naming it that asks for a choice; null when none does. Every Library refresh asks it again.
|
||||
/// </summary>
|
||||
internal CardStatus? StatusOf(Guid id)
|
||||
{
|
||||
var pair = _pairs.FirstOrDefault(p => p.Copy.NeedsAttention && (p.Copy.LocalId == id || p.Copy.OtherId == id || p.Copy.RemoteId == id));
|
||||
return pair is null ? null : LibraryStatus(pair, id);
|
||||
}
|
||||
|
||||
/// <summary>The card status of a sequence of <paramref name="pair"/>.</summary>
|
||||
internal static CardStatus LibraryStatus(FoundCopyView pair, Guid sequenceId)
|
||||
{
|
||||
var copy = pair.Copy;
|
||||
if (copy.RemoteGone || copy.Score.DeletedThere > 0)
|
||||
if (copy.RemoteGone)
|
||||
return new CardStatus(StatusKind.Warning, Loc.L("Library.Status.RemoteGone"), Loc.L("Tooltips.Library.Status.RemoteGone", pair.There.Where));
|
||||
if (copy.Score.DeletedThere > 0)
|
||||
return new CardStatus(StatusKind.Warning, Loc.L("Library.Status.DeletedThere"),
|
||||
Loc.L("Tooltips.Library.Status.DeletedThere", pair.There.Where));
|
||||
var other = copy.Kind == CopyKind.LocalLocal && copy.OtherId == sequenceId ? pair.Here : pair.There;
|
||||
|
||||
@@ -26,7 +26,7 @@ public sealed class CopyClassRow(PhotoClassTotal total) : ObservableObject
|
||||
/// A photo of the Photos part's list: capture time, name, size, where it lies, and per policy a Bring tick (Only here,
|
||||
/// Only there under Choose each), a version choice (Different under Choose each) or Drop… (Two versions).
|
||||
/// </summary>
|
||||
public sealed class CopyPhotoRow : ObservableObject
|
||||
public sealed class CopyPhotoRow : ObservableObject, ISelectableRow
|
||||
{
|
||||
private readonly Action _changed;
|
||||
private readonly bool _swapped;
|
||||
|
||||
@@ -7,10 +7,13 @@ using Chronos.Ui.Mvvm;
|
||||
|
||||
namespace Chronos.App.Server.Copies;
|
||||
|
||||
/// <summary>A line of the Plan part ("Receives 24 photos · 412 MB"); a warning line (last copies) leads its column.</summary>
|
||||
/// <summary>
|
||||
/// A line of the Plan part ("Receives 24 photos · 412 MB"): something that will happen, so a queued glyph, not a done
|
||||
/// tick; a warning line (last copies, the trash) leads its column.
|
||||
/// </summary>
|
||||
public sealed record CopyPlanLine(string Text, string? ToolTip = null, bool IsWarning = false)
|
||||
{
|
||||
public StatusKind Kind => IsWarning ? StatusKind.Warning : StatusKind.Done;
|
||||
public StatusKind Kind => IsWarning ? StatusKind.Warning : StatusKind.Queued;
|
||||
public string ShownToolTip => ToolTip ?? Text;
|
||||
}
|
||||
|
||||
|
||||
@@ -54,13 +54,22 @@ public static class CopyText
|
||||
CopyState.KeptApart => (StatusKind.Offline, Loc.L("Server.Copies.State.KeptApart"),
|
||||
Loc.L("Tooltips.Server.Copies.State.KeptApart", Formatting.Date(copy.AnsweredAt ?? copy.UpdatedAt))),
|
||||
CopyState.Linked => (StatusKind.Synced, Loc.L("Server.Copies.State.Linked"), Loc.L("Tooltips.Server.Copies.State.Linked")),
|
||||
// The share in the cell (it fits the column in both languages); "1,234 of 2,400" in the tooltip.
|
||||
CopyState.Integrating => (StatusKind.Running,
|
||||
Loc.L("Server.Copies.State.Integrating", Formatting.Count(progress?.Done ?? 0), Formatting.Count(progress?.Total ?? 0)),
|
||||
Loc.L("Tooltips.Server.Copies.State.Integrating")),
|
||||
Loc.L("Server.Copies.State.Integrating", Percent(progress)),
|
||||
progress is { Total: > 0 } p
|
||||
? string.Join(Environment.NewLine, Loc.L("Tooltips.Server.Copies.State.Integrating"),
|
||||
Loc.L("Server.Copies.State.Progress", Formatting.Count(p.Done), Formatting.Count(p.Total)))
|
||||
: Loc.L("Tooltips.Server.Copies.State.Integrating")),
|
||||
_ => (StatusKind.Done, Loc.L("Server.Copies.State.Integrated"), Loc.L("Tooltips.Server.Copies.State.Integrated")),
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>How far an Integrate or Merge job came, in whole per cent ("51"); "0" before it reports.</summary>
|
||||
private static string Percent((long Done, long Total)? progress) => progress is { Total: > 0 } p
|
||||
? Math.Clamp(p.Done * 100 / p.Total, 0, 100).ToString("0", Loc.Culture)
|
||||
: "0";
|
||||
|
||||
/// <summary>The share of the smaller side's photos the other holds too, in whole per cent ("98").</summary>
|
||||
public static string SharedPercent(CopyScore score) =>
|
||||
Math.Round(Math.Clamp(score.Containment, 0, 1000) / 10.0).ToString("0", Loc.Culture);
|
||||
@@ -69,8 +78,15 @@ public static class CopyText
|
||||
public static string Where(CopyFacts facts, bool isServer) =>
|
||||
Loc.Plural(isServer ? "Server.Copies.Where.Server" : "Server.Copies.Where.Archive", facts.Photos, facts.Where);
|
||||
|
||||
/// <summary>"Lighthouse · 1,204 photos · 18.2 GB": a side of the dialog's header.</summary>
|
||||
public static string Facts(CopyFacts facts) => Loc.Plural("Server.Copies.Facts", facts.Photos, facts.Where, Formatting.Bytes(facts.Bytes));
|
||||
/// <summary>
|
||||
/// "Main archive · 1,204 photos · 18.2 GB": a side of the dialog's header; "Lighthouse · Main archive · 1,204 photos ·
|
||||
/// 18.2 GB" with <paramref name="withTitle"/> (the two sides' titles differ).
|
||||
/// </summary>
|
||||
public static string Facts(CopyFacts facts, bool withTitle = false)
|
||||
{
|
||||
var text = Loc.Plural("Server.Copies.Facts", facts.Photos, facts.Where, Formatting.Bytes(facts.Bytes));
|
||||
return withTitle && facts.Title.Length > 0 ? Loc.L("Server.Copies.Titled", facts.Title, text) : text;
|
||||
}
|
||||
|
||||
/// <summary>The row's buttons in the order of design §8.1.</summary>
|
||||
public static IReadOnlyList<CopyAction> Actions(FoundCopy copy, Core.Model.JobState? job = null)
|
||||
|
||||
Reference in new issue
Block a user