fix(app): show what a trash restore kept, and drop stale trash translations
The desktop trash dialog sent the "N files stayed in the trash" sentence through ShowError. ArchiveFailures.Cause has no arm for it, so after a partial restore the red line and Narrator said "A file of the archive could not be read or written." The sentence itself appeared only in the tooltip. The same thing happened to an entry none of whose files matches its record. - ArchiveDialogViewModel.ShowMessage shows a sentence that is already localized. The trash dialog uses it for kept files, and its tooltip names the files kept (six of them, then "+ N more"). - ArchiveFailures.Cause passes FrameTrash's Archive.Error.TrashMismatch sentence through. It matches the sentence's text because the engine throws a plain InvalidDataException. Any other InvalidDataException, such as a sidecar that belongs to another sequence, still reads as a file error. - Archive.Trash.List, Tooltips.Archive.Trash and Tooltips.Archive.TrashRestore changed meaning in English: they now cover photo entries as well as sequences. They are removed from the 36 cultures other than en and it, so those cultures fall back to English and `i18n check` lists the keys as untranslated instead of showing the old sequence-only wording. - The XAML comments describe what the trash dialog and its error line show now. Tests: the dialog restores a photo entry and a sequence entry and checks which rows are left. A photo entry with one tampered file shows the KeptFiles sentence and keeps its row. An entry with every file tampered shows the TrashMismatch sentence. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit 2524a11445c87d37625b01095ef7c2a84a2ee422)
This commit is contained in:
1 parent
13278710a2
commit
a133306fb0
77 files changed
+195
-115
No files matched your search
@@ -63,10 +63,10 @@ public abstract class ArchiveDialogViewModel : LocalizedViewModel
|
||||
|
||||
public string? BusyText { get => _busyText; protected set => Set(ref _busyText, value); }
|
||||
|
||||
/// <summary>Why the last dry run or apply stopped (<see cref="ArchiveFailures.Cause"/>); null when nothing failed.</summary>
|
||||
/// <summary>Why the last dry run or apply stopped (<see cref="ArchiveFailures.Cause"/>), or what it left undone; null when nothing failed.</summary>
|
||||
public string? ErrorText { get => _errorText; private set => Set(ref _errorText, value); }
|
||||
|
||||
/// <summary>The failure as the engine reported it, for the tooltip.</summary>
|
||||
/// <summary>The failure as the engine reported it (or what a <see cref="ShowMessage"/> names), for the tooltip.</summary>
|
||||
public string? ErrorToolTip { get => _errorToolTip; private set => Set(ref _errorToolTip, value); }
|
||||
|
||||
protected void Close() => _close(this);
|
||||
@@ -77,6 +77,13 @@ public abstract class ArchiveDialogViewModel : LocalizedViewModel
|
||||
ErrorToolTip = ex.Message;
|
||||
}
|
||||
|
||||
/// <summary>Shows a sentence localized already, such as what an action that half succeeded left undone; <paramref name="tip"/> details it.</summary>
|
||||
protected void ShowMessage(string text, string? tip = null)
|
||||
{
|
||||
ErrorText = text;
|
||||
ErrorToolTip = tip ?? text;
|
||||
}
|
||||
|
||||
protected void ClearError()
|
||||
{
|
||||
ErrorText = null;
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
<Setter Property="AutomationProperties.LiveSetting" Value="Polite" />
|
||||
</Style>
|
||||
|
||||
<!-- A dialog's failure: one sentence in the error colour with its glyph, the engine's own text in the tooltip, announced at once. -->
|
||||
<!-- A dialog's failure: one sentence in the error colour with its glyph, the engine's own text (or what the sentence names) in the tooltip, announced at once. -->
|
||||
<Style x:Key="Status.DialogError" TargetType="ui:StatusGlyph" BasedOn="{StaticResource {x:Type ui:StatusGlyph}}">
|
||||
<Setter Property="Kind" Value="Error" />
|
||||
<Setter Property="FontSize" Value="12" />
|
||||
@@ -203,7 +203,7 @@
|
||||
</Border>
|
||||
</DataTemplate>
|
||||
|
||||
<!-- The archive's trash: deleted sequences, newest first, each with Restore. -->
|
||||
<!-- The archive's trash: deleted sequences and photos deleted from sequences, newest first, each with Restore; Empty… erases them after a dry run and a typed confirmation. -->
|
||||
<DataTemplate DataType="{x:Type ar:TrashDialogViewModel}">
|
||||
<Border Style="{StaticResource Border.Dialog}" Width="640" MaxHeight="520">
|
||||
<Grid>
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using System.IO;
|
||||
using Chronos.App.Infrastructure;
|
||||
using Chronos.Core.Archiving;
|
||||
using Chronos.Core.Localization;
|
||||
@@ -19,6 +20,9 @@ public static class ArchiveFailures
|
||||
// Already one localized sentence each.
|
||||
LeaseUnavailableException or NewerFormatException or StaleRenamePlanException or NestedRenameException or StaleDeletePlanException
|
||||
or SequenceInLibraryException => ex.Message,
|
||||
// A trash entry none of whose files matches its record any more (FrameTrash.RestoreAsync), told by its sentence: other
|
||||
// InvalidDataExceptions, such as a sidecar of another sequence, carry technical text.
|
||||
InvalidDataException when ex.Message == Loc.L("Archive.Error.TrashMismatch") => ex.Message,
|
||||
UnauthorizedAccessException => Loc.L("Archive.Failed.Access"),
|
||||
DatabaseException => Loc.L("Archive.Failed.Index"),
|
||||
ArgumentException => Loc.L("Archive.Failed.Gone"),
|
||||
|
||||
@@ -171,9 +171,10 @@ public sealed class TrashDialogViewModel : ArchiveDialogViewModel
|
||||
BusyText = null;
|
||||
if (result.Kept.Count > 0)
|
||||
{
|
||||
// Files that no longer match their record stay in the trash: the entry stays, with what is left.
|
||||
// Files that no longer match their record stay in the trash: the entry stays, with what is left, and the line
|
||||
// says how many (the tooltip names them).
|
||||
await LoadAsync();
|
||||
ShowError(new InvalidDataException(Loc.Plural("Archive.Trash.KeptFiles", result.Kept.Count)));
|
||||
ShowMessage(Loc.Plural("Archive.Trash.KeptFiles", result.Kept.Count), KeptList(result.Kept));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -194,6 +195,14 @@ public sealed class TrashDialogViewModel : ArchiveDialogViewModel
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>The files a restore kept in the trash, one per line; past <see cref="DeletePlans.ListedLines"/> the rest are counted.</summary>
|
||||
private static string KeptList(IReadOnlyList<string> kept)
|
||||
{
|
||||
var lines = kept.Take(DeletePlans.ListedLines).Select(Formatting.LeftToRight).ToList();
|
||||
if (kept.Count > DeletePlans.ListedLines) lines.Add(Loc.Plural("Archive.Delete.More", kept.Count - DeletePlans.ListedLines));
|
||||
return string.Join(Environment.NewLine, lines);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Empty…: measures every entry (the dry run), asks to type how many entries go, and queues the job that erases exactly
|
||||
/// those; the dialog closes, and the job says how it ended.
|
||||
|
||||
Reference in new issue
Block a user