fix(copies): close the owner review 6 second verification findings

Upload again now deletes the gone pair row once the new sequence is linked, so
the pair stops reading "deleted on server" or "kept here". A linked upload the
server refuses into its sequence (403 for an account without Edit that does not
own it) falls back to ordinary uploads instead of failing; an Integrate that
would add photos to such a sequence is blocked in its plan (NoAddRight).
Automatic photo transfers pause on a metered connection whatever the option
says. Integrate trashes server photos only against the manifest version that
checked the winner, and a merge is blocked while the other sequence holds a
damaged photo nothing else holds (DamagedPhotos), so nothing unverified reaches
the trash.

The plan and the confirmations now say what really happens: replaced versions
are no longer counted as kept, a merge lists the kept sequence's replaced
photos, plan lines use the text colour, an integrated pair that left photos out
says new photos move by hand, and a merging pair reads "merging" with its
progress. The Compare dialog gets per-side tooltips, class sizes for both
sides, policy-aware class tooltips, column headings and readable file names;
the sync table shows "deleted there" with Review and warns on skipped rows; the
Edit picker names the server, the Library card shows the match status second,
a deleted server sequence is named instead of "0 photos", and the match
tooltips stop calling a sequence a copy. The capture scenes use the server
name, the link names and consistent sample sizes.

Refs #73

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Alby96andClaude Opus 5.5 committed 2026-11-17 16:08:49 +01:00
1 parent b34b6b6fe0
commit 9657c1711d
44 files changed
+802 -128

No files matched your search

@@ -158,6 +158,7 @@ public sealed class CopyDialogViewModel : ArchiveDialogViewModel
if (value is null || !Set(ref _policy, value)) return;
OnPropertyChanged(nameof(PolicyToolTip));
OnPropertyChanged(nameof(IsChoosing));
foreach (var row in _classes) row.Policy = value.Value;
BuildPhotos();
Changed();
}
@@ -209,6 +210,18 @@ public sealed class CopyDialogViewModel : ArchiveDialogViewModel
public string AllHereText => Loc.L(IsMerge ? "Server.Copies.Detail.AllKept" : "Server.Copies.Detail.AllThisPc");
public string AllThereText => Loc.L(IsMerge ? "Server.Copies.Detail.AllOther" : "Server.Copies.Detail.AllServer");
/// <summary>"Take this PC's value for every difference." (a merge: the kept sequence's).</summary>
public string AllHereToolTip => Loc.L(IsMerge ? "Tooltips.Server.Copies.Detail.AllKept" : "Tooltips.Server.Copies.Detail.AllHere");
/// <summary>"Take the server's value for every difference." (a merge: the other sequence's).</summary>
public string AllThereToolTip => Loc.L(IsMerge ? "Tooltips.Server.Copies.Detail.AllOther" : "Tooltips.Server.Copies.Detail.AllThere", ServerName);
/// <summary>The Details part's first value column: this PC, or the kept sequence ("Into Old archive"); the pair's first before one is kept.</summary>
public string DetailHereHeading => IsMerge && _keepId is null ? Here.Where : HereHeading;
/// <summary>The Details part's second value column: the server, or the other sequence.</summary>
public string DetailThereHeading => ThereHeading;
/// <summary>A merge keeping the pair's other sequence: the review compares the pair's first with it, so its two columns swap.</summary>
private bool Swapped => IsMerge && _keepId is { } keep && keep == Copy.OtherId;
@@ -340,7 +353,7 @@ public sealed class CopyDialogViewModel : ArchiveDialogViewModel
private void Build(CopyReview review)
{
Classes = [.. review.Photos.Totals.Where(t => t.Count > 0).Select(t => new CopyClassRow(t))];
Classes = [.. review.Photos.Totals.Where(t => t.Count > 0).Select(t => new CopyClassRow(t, _policy.Value, IsMerge) { Swapped = Swapped })];
_class = _classes.FirstOrDefault(c => c.Class == _startClass)
?? _classes.FirstOrDefault(c => c.Class is not (PhotoClass.Same or PhotoClass.Converted))
?? _classes.FirstOrDefault();
@@ -430,10 +443,18 @@ public sealed class CopyDialogViewModel : ArchiveDialogViewModel
var wasSwapped = Swapped;
_keepId = option.SequenceId;
foreach (var other in _keep.Where(o => !ReferenceEquals(o, option))) other.SetQuietly(false);
foreach (var row in _classes) row.Swapped = Swapped;
Reorient(wasSwapped);
RaiseHeadings();
Changed();
}
private void RaiseHeadings()
{
OnPropertyChanged(nameof(HereHeading));
OnPropertyChanged(nameof(ThereHeading));
Changed();
OnPropertyChanged(nameof(DetailHereHeading));
OnPropertyChanged(nameof(DetailThereHeading));
}
/// <summary>A choice changed: the plan follows once the user pauses.</summary>
@@ -503,6 +524,7 @@ public sealed class CopyDialogViewModel : ArchiveDialogViewModel
var wasSwapped = Swapped;
_keepId = merge.KeepId;
foreach (var option in _keep) option.SetQuietly(option.SequenceId == _keepId);
foreach (var row in _classes) row.Swapped = Swapped;
Reorient(wasSwapped);
}
}
@@ -555,11 +577,12 @@ public sealed class CopyDialogViewModel : ArchiveDialogViewModel
var blocks = new List<CopyBlockLine>();
if (_plan is { } plan)
{
// Warnings lead each column: last copies, then the trash.
Lasts(plan.LastCopies, here, there);
Photos(plan.Photos, PhotoAction.Fetch, PhotoAction.FetchVersion, "Server.Copies.Plan.Receives", here);
Photos(plan.Photos, PhotoAction.Send, PhotoAction.SendVersion, "Server.Copies.Plan.Receives", there);
Trash(plan.Photos, PhotoAction.TrashHere, here);
Trash(plan.Photos, PhotoAction.TrashThere, there);
Photos(plan.Photos, PhotoAction.Fetch, PhotoAction.FetchVersion, PhotoAction.TrashHere, "Server.Copies.Plan.Receives", here);
Photos(plan.Photos, PhotoAction.Send, PhotoAction.SendVersion, PhotoAction.TrashThere, "Server.Copies.Plan.Receives", 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")));
// A detail changes on the side that does not keep its own value: this PC takes the server's, the server this PC's.
@@ -580,7 +603,9 @@ public sealed class CopyDialogViewModel : ArchiveDialogViewModel
else if (_merge is { } merge)
{
Lasts(merge.LastCopies, here, there);
Photos(merge.Photos, PhotoAction.Fetch, PhotoAction.FetchVersion, "Server.Copies.Plan.Receives", here);
// The kept sequence's versions the other's replace go to its archive's trash (Other one wins, or chosen so).
Trash(merge.Photos, PhotoAction.TrashHere, here);
Photos(merge.Photos, PhotoAction.Fetch, PhotoAction.FetchVersion, PhotoAction.TrashHere, "Server.Copies.Plan.Receives", here);
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)));
@@ -601,8 +626,7 @@ public sealed class CopyDialogViewModel : ArchiveDialogViewModel
HereLines = here;
ThereLines = there;
Blocks = blocks;
OnPropertyChanged(nameof(HereHeading));
OnPropertyChanged(nameof(ThereHeading));
RaiseHeadings();
OnPropertyChanged(nameof(ApplyToolTip));
_apply.RaiseCanExecuteChanged();
@@ -614,11 +638,12 @@ public sealed class CopyDialogViewModel : ArchiveDialogViewModel
if (theirs > 0) t.Add(new(Loc.Plural("Server.Copies.Plan.LastCopies", theirs), Loc.L("Tooltips.Server.Copies.Plan.LastCopies"), true));
}
static void Photos(IReadOnlyList<PhotoStep> steps, PhotoAction a, PhotoAction b, string key, List<CopyPlanLine> lines)
// A version step whose photo has a trash step on the same side replaces it: received, not kept as a second version.
static void Photos(IReadOnlyList<PhotoStep> steps, PhotoAction a, PhotoAction b, PhotoAction trash, string key, List<CopyPlanLine> lines)
{
var moving = steps.Where(s => s.Action == a || s.Action == b).ToList();
if (moving.Count > 0) lines.Add(new(Loc.Plural(key, moving.Count, Formatting.Bytes(moving.Sum(s => s.Bytes)))));
var kept = steps.Count(s => s.Action == b);
var kept = KeptVersions(steps, b, trash);
if (kept > 0) lines.Add(new(Loc.Plural("Server.Copies.Plan.Versions", kept)));
}
@@ -665,7 +690,7 @@ public sealed class CopyDialogViewModel : ArchiveDialogViewModel
{
if (_plan is { CanApply: true } plan)
{
if (plan.Destructive && !_shell.Services.Dialogs.Confirm(ReplaceRequest(plan, plan.Context?.ServerName ?? ServerName))) return;
if (plan.Destructive && !_shell.Services.Dialogs.Confirm(ReplaceRequest(plan))) return;
IsBusy = true;
await _engine.EnqueueIntegrateAsync(jobs, plan, CancellationToken.None);
}
@@ -808,11 +833,24 @@ public sealed class CopyDialogViewModel : ArchiveDialogViewModel
await LoadAsync();
}
/// <summary>
/// The second versions <paramref name="version"/> steps keep beside their pair: a version step whose photo has a
/// <paramref name="trash"/> step on the same side replaces it instead (This PC wins, Server wins, Other one wins).
/// </summary>
internal static int KeptVersions(IReadOnlyList<PhotoStep> steps, PhotoAction version, PhotoAction trash)
{
var replaced = steps.Where(s => s.Action == trash).Select(s => s.Key).ToHashSet(StringComparer.Ordinal);
return steps.Count(s => s.Action == version && !replaced.Contains(s.Key));
}
/// <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)
internal ConfirmRequest ReplaceRequest(IntegratePlan plan) => ReplaceRequest(plan, plan.Context?.ServerName ?? ServerName);
/// <inheritdoc cref="ReplaceRequest(IntegratePlan)"/>
internal static ConfirmRequest ReplaceRequest(IntegratePlan plan, string? server)
{
var trashed = plan.Photos.Where(p => p.Action is PhotoAction.TrashHere or PhotoAction.TrashThere).ToList();
var name = server ?? plan.Context?.ServerName ?? string.Empty;
@@ -836,6 +874,14 @@ public sealed class CopyDialogViewModel : ArchiveDialogViewModel
var drop = plan.KeepId == Copy.LocalId ? There : Here;
var only = _review?.Photos.Of(plan.KeepId == Copy.LocalId ? PhotoClass.OnlyThere : PhotoClass.OnlyHere).Count() ?? 0;
var facts = new List<string> { Loc.Plural("Server.Copies.Plan.DropToTrash", drop.Photos, Formatting.Bytes(drop.Bytes)) };
// The kept sequence's own versions the other's replace go to its trash too: named, the last copies among them first.
var lastKeys = plan.LastCopies.Where(l => l.Side == CopySide.ThisPc).Select(l => l.Key).ToHashSet(StringComparer.Ordinal);
var replaced = plan.Photos.Where(p => p.Action == PhotoAction.TrashHere).ToList();
if (replaced.Count > 0)
{
facts.Add(Loc.Plural("Server.Copies.Confirm.Merge.Replaced", replaced.Count, keep.Where));
facts.AddRange(replaced.Where(p => !lastKeys.Contains(p.Key) && !lastKeys.Contains(p.Sha256 ?? string.Empty)).Select(p => " " + p.FileName));
}
if (only > 0) facts.Add(Loc.Plural("Server.Copies.Confirm.Merge.OnlyHere", only, drop.Where));
if (plan.Renders.Count > 0) facts.Add(Loc.Plural("Server.Copies.Plan.Renders", plan.Renders.Count));
if (plan.Projects.Count > 0) facts.Add(Loc.Plural("Server.Copies.Plan.Projects", plan.Projects.Count));
+73 -34
View File
@@ -27,6 +27,18 @@
<Setter Property="ToolTip" Value="{Binding ToolTip}" />
</Style>
<!-- A plan line reads as text to act on, not as a disabled one: the ring stays, the words take the text colour (a
style trigger outranks the glyph template's Queued colour); warnings keep theirs. -->
<Style x:Key="Status.PlanLine" TargetType="ui:StatusGlyph" BasedOn="{StaticResource {x:Type ui:StatusGlyph}}">
<Setter Property="FontSize" Value="12" />
<Setter Property="Margin" Value="0,0,0,4" />
<Style.Triggers>
<DataTrigger Binding="{Binding IsWarning}" Value="False">
<Setter Property="Foreground" Value="{DynamicResource Brush.Text}" />
</DataTrigger>
</Style.Triggers>
</Style>
<DataTemplate DataType="{x:Type cp:CopyDialogViewModel}">
<Border Style="{StaticResource Border.Dialog}" Width="920" MaxHeight="600">
<Grid>
@@ -73,24 +85,36 @@
<ComboBox Width="170" ItemsSource="{Binding Policies}" SelectedItem="{Binding Policy}" DisplayMemberPath="Label" ToolTip="{Binding PolicyToolTip}"
ItemContainerStyle="{StaticResource ComboBoxItem.Option}" AutomationProperties.Name="{l:Loc Server.Copies.Policy.Label}" />
</StackPanel>
<ListBox Grid.Row="1" ItemsSource="{Binding Classes}" SelectedItem="{Binding SelectedClass}" ItemContainerStyle="{StaticResource ListBoxItem.CopyClass}"
ScrollViewer.HorizontalScrollBarVisibility="Disabled" AutomationProperties.Name="{l:Loc Server.Copies.Part.Photos}" Margin="0,0,14,0">
<ListBox.ItemTemplate>
<DataTemplate DataType="{x:Type cp:CopyClassRow}">
<Grid Height="28">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="56" />
<ColumnDefinition Width="70" />
</Grid.ColumnDefinitions>
<ui:StatusGlyph Kind="{Binding Kind}" Text="{Binding Text}" FontSize="12" VerticalAlignment="Center" />
<TextBlock Grid.Column="1" Text="{Binding CountText}" TextAlignment="Right" VerticalAlignment="Center" Typography.NumeralAlignment="Tabular" />
<TextBlock Grid.Column="2" Text="{Binding HereBytesText}" TextAlignment="Right" VerticalAlignment="Center" Foreground="{DynamicResource Brush.TextMuted}"
Typography.NumeralAlignment="Tabular" FontSize="12" />
</Grid>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
<DockPanel Grid.Row="1" Margin="0,0,14,0">
<!-- Column headings: the class, how many photos, their size (on the side that holds them). -->
<Grid DockPanel.Dock="Top" Margin="15,0,15,4">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="56" />
<ColumnDefinition Width="70" />
</Grid.ColumnDefinitions>
<TextBlock Grid.Column="1" Text="{l:Loc Server.Copies.Part.Photos}" Style="{StaticResource Text.ColumnHeader}" TextAlignment="Right" TextTrimming="CharacterEllipsis" />
<TextBlock Grid.Column="2" Text="{l:Loc Server.Copies.Photo.Size}" Style="{StaticResource Text.ColumnHeader}" TextAlignment="Right" TextTrimming="CharacterEllipsis" />
</Grid>
<ListBox ItemsSource="{Binding Classes}" SelectedItem="{Binding SelectedClass}" ItemContainerStyle="{StaticResource ListBoxItem.CopyClass}"
ScrollViewer.HorizontalScrollBarVisibility="Disabled" AutomationProperties.Name="{l:Loc Server.Copies.Part.Photos}">
<ListBox.ItemTemplate>
<DataTemplate DataType="{x:Type cp:CopyClassRow}">
<Grid Height="28">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="56" />
<ColumnDefinition Width="70" />
</Grid.ColumnDefinitions>
<ui:StatusGlyph Kind="{Binding Kind}" Text="{Binding Text}" FontSize="12" VerticalAlignment="Center" />
<TextBlock Grid.Column="1" Text="{Binding CountText}" TextAlignment="Right" VerticalAlignment="Center" Typography.NumeralAlignment="Tabular" />
<TextBlock Grid.Column="2" Text="{Binding BytesText}" ToolTip="{Binding BytesToolTip}" TextAlignment="Right" VerticalAlignment="Center"
Foreground="{DynamicResource Brush.TextMuted}" Typography.NumeralAlignment="Tabular" FontSize="12" />
</Grid>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</DockPanel>
<!-- Bring all / Bring none, All: keep both, To trash…, Delete on server…: above the list they act on. -->
<WrapPanel Grid.Column="1" VerticalAlignment="Center" Margin="0,0,0,8">
<Button Style="{StaticResource Button.Link}" Content="{l:Loc Server.Copies.Photo.BringAll}" Command="{Binding BringAllCommand}"
@@ -114,22 +138,23 @@
<ListBox.ItemTemplate>
<DataTemplate DataType="{x:Type cp:CopyPhotoRow}">
<Grid MinHeight="28" ToolTip="{Binding ToolTip}">
<!-- A Different photo is on both sides: under Choose each its side cell gives way to the name (the choice says the side). -->
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="150" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="80" />
<ColumnDefinition Width="110" />
<ColumnDefinition Width="140" />
<ColumnDefinition Width="*" MinWidth="110" />
<ColumnDefinition Width="72" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<CheckBox IsChecked="{Binding Bring}" ToolTip="{l:Loc Tooltips.Server.Copies.Bring}" AutomationProperties.Name="{Binding BringAccessibleName}"
VerticalAlignment="Center" Margin="0,0,8,0" Visibility="{Binding CanBring, Converter={StaticResource CopyBoolToVisibility}}" />
<TextBlock Grid.Column="1" Text="{Binding TimeText}" VerticalAlignment="Center" Typography.NumeralAlignment="Tabular" FontSize="12" />
<TextBlock Grid.Column="1" Text="{Binding TimeText}" VerticalAlignment="Center" Typography.NumeralAlignment="Tabular" FontSize="12" TextTrimming="CharacterEllipsis" />
<TextBlock Grid.Column="2" Text="{Binding Name}" VerticalAlignment="Center" TextTrimming="CharacterEllipsis" FlowDirection="LeftToRight" FontSize="12" />
<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="150" ItemsSource="{Binding Choices}" SelectedItem="{Binding Choice}" DisplayMemberPath="Label"
<TextBlock Grid.Column="4" Width="110" Text="{Binding SideText}" VerticalAlignment="Center" Foreground="{DynamicResource Brush.TextMuted}" Margin="10,0,0,0"
TextTrimming="CharacterEllipsis" FontSize="12" Visibility="{Binding CanChoose, Converter={x:Static ui:InverseBoolToVisibilityConverter.Instance}}" />
<ComboBox Grid.Column="5" Width="150" Margin="10,0,0,0" 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}"
@@ -144,16 +169,30 @@
</Grid>
<!-- Details: one line per difference, nothing preselected. -->
<Grid Visibility="{Binding IsDetails, Converter={StaticResource CopyBoolToVisibility}}">
<Grid Visibility="{Binding IsDetails, Converter={StaticResource CopyBoolToVisibility}}" Grid.IsSharedSizeScope="True">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<StackPanel Orientation="Horizontal" Margin="0,0,0,8" Visibility="{Binding HasDetails, Converter={StaticResource CopyBoolToVisibility}}">
<Button Style="{StaticResource Button.Link}" Content="{Binding AllHereText}" Command="{Binding AllHereCommand}" ToolTip="{l:Loc Tooltips.Server.Copies.Detail.All}" Margin="0,0,14,0" />
<Button Style="{StaticResource Button.Link}" Content="{Binding AllThereText}" Command="{Binding AllThereCommand}" ToolTip="{l:Loc Tooltips.Server.Copies.Detail.All}" />
<Button Style="{StaticResource Button.Link}" Content="{Binding AllHereText}" Command="{Binding AllHereCommand}" ToolTip="{Binding AllHereToolTip}" Margin="0,0,14,0" />
<Button Style="{StaticResource Button.Link}" Content="{Binding AllThereText}" Command="{Binding AllThereCommand}" ToolTip="{Binding AllThereToolTip}" />
</StackPanel>
<ItemsControl Grid.Row="1" ItemsSource="{Binding Details}" Focusable="False" Visibility="{Binding HasDetails, Converter={StaticResource CopyBoolToVisibility}}">
<!-- Whose value each column holds: this PC and the server, or the kept sequence and the other (they follow the kept one). -->
<Grid Grid.Row="1" Margin="0,0,0,6" Visibility="{Binding HasDetails, Converter={StaticResource CopyBoolToVisibility}}">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="180" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" SharedSizeGroup="CopyDetailChoice" />
</Grid.ColumnDefinitions>
<TextBlock Grid.Column="1" Text="{Binding DetailHereHeading}" ToolTip="{Binding DetailHereHeading}" Style="{StaticResource Text.ColumnHeader}"
TextTrimming="CharacterEllipsis" Margin="10,0,0,0" />
<TextBlock Grid.Column="2" Text="{Binding DetailThereHeading}" ToolTip="{Binding DetailThereHeading}" Style="{StaticResource Text.ColumnHeader}"
TextTrimming="CharacterEllipsis" Margin="10,0,0,0" />
</Grid>
<ItemsControl Grid.Row="2" ItemsSource="{Binding Details}" Focusable="False" Visibility="{Binding HasDetails, Converter={StaticResource CopyBoolToVisibility}}">
<ItemsControl.Template>
<ControlTemplate TargetType="ItemsControl">
<ScrollViewer VerticalScrollBarVisibility="Auto" Focusable="False">
@@ -168,7 +207,7 @@
<ColumnDefinition Width="180" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" SharedSizeGroup="CopyDetailChoice" />
</Grid.ColumnDefinitions>
<TextBlock Text="{Binding Label}" Style="{StaticResource Text.DialogLabel}" VerticalAlignment="Center" TextTrimming="CharacterEllipsis" ToolTip="{Binding Label}" />
<TextBlock Grid.Column="1" Text="{Binding HereText}" ToolTip="{Binding HereToolTip}" VerticalAlignment="Center" TextTrimming="CharacterEllipsis" Margin="10,0,0,0" />
@@ -181,7 +220,7 @@
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
<TextBlock Grid.Row="1" Text="{Binding DetailsEmptyText}" Foreground="{DynamicResource Brush.TextMuted}"
<TextBlock Grid.Row="2" Text="{Binding DetailsEmptyText}" Foreground="{DynamicResource Brush.TextMuted}"
Visibility="{Binding DetailsEmptyText, Converter={x:Static ui:NullToCollapsedConverter.Instance}}" />
</Grid>
@@ -257,7 +296,7 @@
<ItemsControl ItemsSource="{Binding HereLines}" Focusable="False">
<ItemsControl.ItemTemplate>
<DataTemplate DataType="{x:Type cp:CopyPlanLine}">
<ui:StatusGlyph Kind="{Binding Kind}" Text="{Binding Text}" ToolTip="{Binding ShownToolTip}" FontSize="12" Margin="0,0,0,4" />
<ui:StatusGlyph Kind="{Binding Kind}" Text="{Binding Text}" ToolTip="{Binding ShownToolTip}" Style="{StaticResource Status.PlanLine}" />
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
@@ -267,7 +306,7 @@
<ItemsControl ItemsSource="{Binding ThereLines}" Focusable="False">
<ItemsControl.ItemTemplate>
<DataTemplate DataType="{x:Type cp:CopyPlanLine}">
<ui:StatusGlyph Kind="{Binding Kind}" Text="{Binding Text}" ToolTip="{Binding ShownToolTip}" FontSize="12" Margin="0,0,0,4" />
<ui:StatusGlyph Kind="{Binding Kind}" Text="{Binding Text}" ToolTip="{Binding ShownToolTip}" Style="{StaticResource Status.PlanLine}" />
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
@@ -180,10 +180,10 @@ public sealed class CopyListViewModel : ObservableObject, IDisposable
}
/// <summary>Opens the Compare dialog of the pair the sequence is in (Library › Compare…); false when it is in none.</summary>
public bool Compare(Guid sequenceId)
public bool Compare(Guid sequenceId, PhotoClass? photos = null)
{
if (_pairs.FirstOrDefault(p => p.Copy.Id == PairOf(sequenceId)?.Id) is not { } pair) return false;
Open(pair, CopyDialogPart.Photos);
Open(pair, CopyDialogPart.Photos, photos);
return true;
}
@@ -431,7 +431,7 @@ public sealed class CopyListViewModel : ObservableObject, IDisposable
private void OnJobChanged(Job job)
{
if (job.Kind is not (JobKind.Integrate or JobKind.MergeSequences)) return;
if (!Follows(job.Kind)) return;
Dispatch(() =>
{
foreach (var row in Rows.Where(r => r.Copy.JobId == job.Id)) row.UpdateJob(job.State, job.ProgressDone, job.ProgressTotal);
@@ -441,13 +441,16 @@ public sealed class CopyListViewModel : ObservableObject, IDisposable
private void OnProgress(JobProgressInfo info)
{
if (info.Kind is not JobKind.Integrate) return;
if (!Follows(info.Kind)) return;
Dispatch(() =>
{
foreach (var row in Rows.Where(r => r.Copy.JobId == info.JobId)) row.UpdateJob(JobState.Running, info.Done, info.Total);
});
}
/// <summary>The jobs a pair's row follows: an Integrate, and a Merge, whose steps come through Progress only (MergeJobHandler).</summary>
internal static bool Follows(JobKind kind) => kind is JobKind.Integrate or JobKind.MergeSequences;
private static void Dispatch(Action action)
{
if (System.Windows.Application.Current?.Dispatcher is not { } dispatcher || dispatcher.CheckAccess()) action();
+59 -3
View File
@@ -9,17 +9,73 @@ using Chronos.Ui.Mvvm;
namespace Chronos.App.Server.Copies;
/// <summary>A line of the Photos part's class table: glyph and class, count, bytes on each side, what it means.</summary>
public sealed class CopyClassRow(PhotoClassTotal total) : ObservableObject
/// <summary>
/// A line of the Photos part's class table: glyph and class, count, size (this side's, else the other side's; both in the
/// tooltip when both sides hold bytes), and what the run does with it under the chosen policy.
/// </summary>
public sealed class CopyClassRow(PhotoClassTotal total, CopyPhotoPolicy policy = CopyPhotoPolicy.Union, bool isMerge = false) : ObservableObject
{
private CopyPhotoPolicy _policy = policy;
private bool _swapped;
public PhotoClass Class { get; } = total.Class;
public StatusKind Kind => CopyText.ClassKind(Class);
public string Text => CopyText.Class(Class);
public string CountText => Formatting.Count(total.Count);
public string HereBytesText => total.HereBytes > 0 ? Formatting.Bytes(total.HereBytes) : string.Empty;
public string ThereBytesText => total.ThereBytes > 0 ? Formatting.Bytes(total.ThereBytes) : string.Empty;
public string ToolTip => CopyText.ClassToolTip(Class);
/// <summary>The size cell: this side's bytes, or the other side's when this side holds none (Only there, Deleted here).</summary>
public string BytesText => total.HereBytes > 0 ? HereBytesText : ThereBytesText;
/// <summary>"This PC 51.4 MB · Server 51.8 MB" when both sides hold bytes (Different); otherwise the side the cell shows.</summary>
public string? BytesToolTip
{
get
{
var here = total.HereBytes > 0 ? Side(true) + " " + HereBytesText : null;
var there = total.ThereBytes > 0 ? Side(false) + " " + ThereBytesText : null;
return here is null && there is null ? null : string.Join(Loc.Separator, new[] { here, there }.Where(s => s is not null));
}
}
/// <summary>The policy the dialog runs with; the tooltip follows it.</summary>
public CopyPhotoPolicy Policy
{
get => _policy;
set
{
if (Set(ref _policy, value)) OnPropertyChanged(nameof(ToolTip));
}
}
/// <summary>A merge keeping the pair's other sequence: this PC's side is the dropped one.</summary>
public bool Swapped
{
get => _swapped;
set
{
if (!Set(ref _swapped, value)) return;
OnPropertyChanged(nameof(ToolTip));
OnPropertyChanged(nameof(BytesToolTip));
}
}
public string ToolTip => CopyText.ClassToolTip(Oriented, _policy, isMerge);
public int Count => total.Count;
/// <summary>The class seen from the kept sequence (a swapped merge reads Only here as the other's photos).</summary>
private PhotoClass Oriented => !isMerge || !_swapped ? Class : Class switch
{
PhotoClass.OnlyHere => PhotoClass.OnlyThere,
PhotoClass.OnlyThere => PhotoClass.OnlyHere,
PhotoClass.DeletedHere => PhotoClass.DeletedThere,
PhotoClass.DeletedThere => PhotoClass.DeletedHere,
_ => Class,
};
private string Side(bool here) => Loc.L(isMerge ? (here != _swapped ? "Server.Copies.Detail.Kept" : "Server.Copies.Detail.Other")
: here ? "Server.Copies.Detail.ThisPc" : "Server.Copies.Detail.Server");
}
/// <summary>
+1 -1
View File
@@ -82,7 +82,7 @@ public sealed class CopyRow : ObservableObject
: string.Join(Loc.Separator, _view.Here.Title, _view.There.Title);
public string HereText => CopyText.Where(_view.Here, isServer: false);
public string ThereText => CopyText.Where(_view.There, isServer: Copy.Kind == CopyKind.LocalServer);
public string ThereText => CopyText.Where(_view.There, isServer: Copy.Kind == CopyKind.LocalServer, Copy.RemoteGone);
public StatusKind StateKind => CopyText.State(Copy, _rights.ServerName, _progress).Kind;
public string StateText => CopyText.State(Copy, _rights.ServerName, _progress).Text;
+2 -1
View File
@@ -90,7 +90,8 @@ public static class CopyScenes
if (await ShowAsync(shell, "server-copies-plan") is not { } dialog) return null;
dialog.Policy = dialog.Policies.First(o => o.Value == CopyPhotoPolicy.ThisPcWins);
await dialog.PlanNowAsync();
var request = dialog.Plan is { } plan ? CopyDialogViewModel.ReplaceRequest(plan) : null;
// Worded as the dialog words it: the plan's server name, else the signed-in one's.
var request = dialog.Plan is { } plan ? dialog.ReplaceRequest(plan) : null;
shell.Server.CloseDialog(dialog);
return request;
}
+40 -12
View File
@@ -54,17 +54,23 @@ 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", 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")),
// The share in the cell (it fits the column in both languages); "1,234 of 2,400" in the tooltip. A pair of this
// PC's archives is being merged, not integrated.
CopyState.Integrating => Running(copy.Kind == CopyKind.LocalLocal ? "Merging" : "Integrating", progress),
// An Integrate that left photos out moves new photos only on Upload and Download (IntegrateJobHandler).
_ when copy.Kind == CopyKind.LocalServer && !copy.AutoPhotos =>
(StatusKind.Done, Loc.L("Server.Copies.State.Integrated"), Loc.L("Tooltips.Server.Copies.State.IntegratedByHand")),
_ => (StatusKind.Done, Loc.L("Server.Copies.State.Integrated"), Loc.L("Tooltips.Server.Copies.State.Integrated")),
};
}
private static (StatusKind, string, string) Running(string word, (long Done, long Total)? progress) => (StatusKind.Running,
Loc.L("Server.Copies.State." + word, Percent(progress)),
progress is { Total: > 0 } p
? string.Join(Environment.NewLine, Loc.L("Tooltips.Server.Copies.State." + word),
Loc.L("Server.Copies.State.Progress", Formatting.Count(p.Done), Formatting.Count(p.Total)))
: Loc.L("Tooltips.Server.Copies.State." + word));
/// <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)
@@ -74,9 +80,12 @@ public static class CopyText
public static string SharedPercent(CopyScore score) =>
Math.Round(Math.Clamp(score.Containment, 0, 1000) / 10.0).ToString("0", Loc.Culture);
/// <summary>"Main archive · 1,204 photos": where one side of a pair lies.</summary>
public static string Where(CopyFacts facts, bool isServer) =>
Loc.Plural(isServer ? "Server.Copies.Where.Server" : "Server.Copies.Where.Archive", facts.Photos, facts.Where);
/// <summary>
/// "Main archive · 1,204 photos": where one side of a pair lies; the server's name alone once it deleted its sequence
/// (<paramref name="gone"/>: no count is known, and "0 photos" would read as an empty sequence).
/// </summary>
public static string Where(CopyFacts facts, bool isServer, bool gone = false) => gone && facts.Where.Length > 0 ? facts.Where
: Loc.Plural(isServer ? "Server.Copies.Where.Server" : "Server.Copies.Where.Archive", facts.Photos, facts.Where);
/// <summary>
/// "Main archive · 1,204 photos · 18.2 GB": a side of the dialog's header; "Lighthouse · Main archive · 1,204 photos ·
@@ -159,7 +168,26 @@ public static class CopyText
/// <summary>The word of a photo class ("Only here").</summary>
public static string Class(PhotoClass c) => Loc.L("Server.Copies.Class." + c);
public static string ClassToolTip(PhotoClass c) => Loc.L("Tooltips.Server.Copies.Class." + c);
/// <summary>
/// What a class means and what the run does with it under <paramref name="policy"/>: Different by the winning side or
/// the per-photo choice, Only here and Only there ticked under Choose each, and a merge's own wording (the other
/// sequence's photos all come in; the kept one's stay). A merge's classes are read from the kept sequence's side.
/// </summary>
public static string ClassToolTip(PhotoClass c, CopyPhotoPolicy policy = CopyPhotoPolicy.Union, bool isMerge = false)
{
var variant = (c, policy) switch
{
(PhotoClass.Differs, CopyPhotoPolicy.ThisPcWins) => isMerge ? ".KeptWins" : ".ThisPcWins",
(PhotoClass.Differs, CopyPhotoPolicy.OtherWins) => isMerge ? ".OtherCopyWins" : ".OtherWins",
(PhotoClass.Differs, CopyPhotoPolicy.ChoosePerPhoto) => ".Choose",
(PhotoClass.Differs, _) when isMerge => ".Merge",
(PhotoClass.OnlyHere or PhotoClass.OnlyThere, _) when isMerge => ".Merge",
(PhotoClass.OnlyHere or PhotoClass.OnlyThere, CopyPhotoPolicy.ChoosePerPhoto) => ".Choose",
(PhotoClass.SameUnhashed, _) when !isMerge => ".Integrate",
_ => string.Empty,
};
return Loc.L("Tooltips.Server.Copies.Class." + c + variant);
}
/// <summary>The glyph of a photo class: what an Integrate settles by itself is fine; what waits for a choice is a warning.</summary>
public static StatusKind ClassKind(PhotoClass c) => c switch
@@ -177,7 +205,7 @@ public static class CopyText
CopyBlock.NeedsNewerServer => Loc.L("Errors.Copies.NeedsNewerServer", server ?? string.Empty),
CopyBlock.LinkTaken => Loc.L("Errors.Copies.LinkTaken", title, server ?? string.Empty),
CopyBlock.NoSpace => Loc.L("Errors.Copies.NoSpace", title, need ?? string.Empty),
CopyBlock.ArchiveOffline or CopyBlock.FolderMoved or CopyBlock.ChangedFile => Loc.L("Errors.Copies." + block, title),
CopyBlock.ArchiveOffline or CopyBlock.FolderMoved or CopyBlock.ChangedFile or CopyBlock.DamagedPhotos => Loc.L("Errors.Copies." + block, title),
CopyBlock.UnsentWorkspace => Loc.L("Errors.Copies.Unsent", title),
CopyBlock.BothLinked => Loc.L("Errors.Copies.BothLinked", server ?? string.Empty),
CopyBlock.TrashBlocked => Loc.L("Errors.Copies.TrashBlocked", title, need ?? string.Empty),