fix(app): failure toasts are announced at once

Shell.Notify takes isError; every toast that reports a failure or a refusal
sets it (archive actions and fixes, sync, settings import and cache, proxy
fetch, welcome folder check, card check, erase, format and eject). The
Uploader marks its unexpected-error, sign-out and choose-a-sequence toasts.

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-06 20:56:08 +00:00
1 parent 37ed91500d
commit a09ef98eac
9 files changed
+27 -20

No files matched your search

@@ -177,7 +177,7 @@ public sealed class ImportResultViewModel : LocalizedViewModel
catch (Exception ex) when (ex is IOException or UnauthorizedAccessException or DatabaseException) catch (Exception ex) when (ex is IOException or UnauthorizedAccessException or DatabaseException)
{ {
Log.Warning("import", "Card check failed", ex); Log.Warning("import", "Card check failed", ex);
_shell.Notify(Loc.L("Import.Toast.CheckFailed"), ex.Message); _shell.Notify(Loc.L("Import.Toast.CheckFailed"), ex.Message, isError: true);
} }
finally finally
{ {
@@ -212,7 +212,7 @@ public sealed class ImportResultViewModel : LocalizedViewModel
catch (Exception ex) when (ex is IOException or UnauthorizedAccessException) catch (Exception ex) when (ex is IOException or UnauthorizedAccessException)
{ {
Log.Warning("import", "Deleting imported photos failed", ex); Log.Warning("import", "Deleting imported photos failed", ex);
_shell.Notify(Loc.L("Import.Toast.DeleteFailed"), ex.Message); _shell.Notify(Loc.L("Import.Toast.DeleteFailed"), ex.Message, isError: true);
} }
finally finally
{ {
@@ -263,12 +263,12 @@ public sealed class ImportResultViewModel : LocalizedViewModel
if (!unchanged) if (!unchanged)
{ {
Actions = _actions with { Erase = null, Card = null }; Actions = _actions with { Erase = null, Card = null };
_shell.Notify(Loc.L("Import.Toast.CardChanged", name), Loc.L("Import.Blocked.NoDryRun")); _shell.Notify(Loc.L("Import.Toast.CardChanged", name), Loc.L("Import.Blocked.NoDryRun"), isError: true);
return; return;
} }
var outcome = _shell.Services.Devices.Format(device); var outcome = _shell.Services.Devices.Format(device);
if (outcome == FormatOutcome.Formatted) Actions = _actions with { Erase = null, Card = null }; if (outcome == FormatOutcome.Formatted) Actions = _actions with { Erase = null, Card = null };
if (outcome != FormatOutcome.Cancelled) _shell.Notify(Loc.L("Import.Toast.Format." + outcome, name)); if (outcome != FormatOutcome.Cancelled) _shell.Notify(Loc.L("Import.Toast.Format." + outcome, name), isError: outcome == FormatOutcome.Failed);
} }
/// <summary>The first files that were never imported, one per line.</summary> /// <summary>The first files that were never imported, one per line.</summary>
@@ -286,7 +286,7 @@ public sealed class ImportResultViewModel : LocalizedViewModel
try try
{ {
var outcome = await Task.Run(() => _shell.Services.Devices.Eject(device)); var outcome = await Task.Run(() => _shell.Services.Devices.Eject(device));
_shell.Notify(Loc.L("Import.Toast.Eject." + outcome, _card?.Nickname ?? device.Label)); _shell.Notify(Loc.L("Import.Toast.Eject." + outcome, _card?.Nickname ?? device.Label), isError: outcome != EjectOutcome.Ejected);
if (outcome == EjectOutcome.Ejected) SetDevice(null); if (outcome == EjectOutcome.Ejected) SetDevice(null);
} }
finally finally
@@ -56,7 +56,7 @@ public static class ArchiveActions
or Data.DatabaseException) or Data.DatabaseException)
{ {
Log.Error("archive", "Archive action failed", ex); Log.Error("archive", "Archive action failed", ex);
shell.Notify(Core.Localization.Loc.L("Errors.Archive.Open"), ex.Message); shell.Notify(Core.Localization.Loc.L("Errors.Archive.Open"), ex.Message, isError: true);
return false; return false;
} }
} }
+2 -1
View File
@@ -900,5 +900,6 @@ public sealed class ArchiveViewModel : SectionViewModel
/// <summary>An action stopped: what stopped, why in one sentence, and Retry to run it again (BRIEF §0.2 rule 6).</summary> /// <summary>An action stopped: what stopped, why in one sentence, and Retry to run it again (BRIEF §0.2 rule 6).</summary>
private void NotifyFailure(string titleKey, Exception ex, ICommand retry) => private void NotifyFailure(string titleKey, Exception ex, ICommand retry) =>
Shell.Notify(Loc.L(titleKey), ArchiveFailures.Cause(ex), Loc.L("Archive.Failed.Retry"), Loc.L("Tooltips.Archive.Retry"), () => retry.Execute(null)); Shell.Notify(Loc.L(titleKey), ArchiveFailures.Cause(ex), Loc.L("Archive.Failed.Retry"), Loc.L("Tooltips.Archive.Retry"), () => retry.Execute(null),
isError: true);
} }
+1 -1
View File
@@ -197,7 +197,7 @@ public sealed class SequenceViewModel : SectionViewModel
break; break;
case JobState.Failed: case JobState.Failed:
Shell.Notify(Loc.L("Editor.Proxies.Failed"), job.Error ?? fetch.Title, Loc.L("Shell.Nav.Jobs"), Loc.L("Tooltips.Nav.Jobs"), Shell.Notify(Loc.L("Editor.Proxies.Failed"), job.Error ?? fetch.Title, Loc.L("Shell.Nav.Jobs"), Loc.L("Tooltips.Nav.Jobs"),
() => Shell.Navigate(SectionKey.Jobs)); () => Shell.Navigate(SectionKey.Jobs), isError: true);
break; break;
} }
} }
+2 -2
View File
@@ -661,7 +661,7 @@ public sealed class SettingsViewModel : SectionViewModel
Shell.Services.Thumbnails?.Clear(); Shell.Services.Thumbnails?.Clear();
if (!CacheStore.IsOwned(folder)) if (!CacheStore.IsOwned(folder))
{ {
Shell.Notify(Loc.L("Settings.Storage.NotOwned")); Shell.Notify(Loc.L("Settings.Storage.NotOwned"), isError: true);
return; return;
} }
var freed = await Task.Run(() => CacheStore.Clear(folder)); var freed = await Task.Run(() => CacheStore.Clear(folder));
@@ -776,7 +776,7 @@ public sealed class SettingsViewModel : SectionViewModel
} }
if (imported is null) if (imported is null)
{ {
Shell.Notify(Loc.L("Errors.Settings.Import")); Shell.Notify(Loc.L("Errors.Settings.Import"), isError: true);
return; return;
} }
// Everything but the session, the window and the first-run flag. // Everything but the session, the window and the first-run flag.
+1 -1
View File
@@ -204,7 +204,7 @@ public sealed class WelcomeViewModel : LocalizedViewModel
case WelcomeChoice.LocalArchive: case WelcomeChoice.LocalArchive:
if (ArchiveLocations.Validate(LocalRoot) is { } problem) if (ArchiveLocations.Validate(LocalRoot) is { } problem)
{ {
_shell.Notify(problem); _shell.Notify(problem, isError: true);
return; return;
} }
if (!await ArchiveActions.TryAsync(_shell, s => s.CreateAsync(LocalRoot))) return; if (!await ArchiveActions.TryAsync(_shell, s => s.CreateAsync(LocalRoot))) return;
+2 -2
View File
@@ -317,7 +317,7 @@ public sealed class SyncTableViewModel : ObservableObject, IDisposable
case SyncAction.DownloadOriginals: case SyncAction.DownloadOriginals:
if ((entry.Local?.ArchiveId ?? (await Host.CurrentArchiveAsync())?.Id) is not { } archive) if ((entry.Local?.ArchiveId ?? (await Host.CurrentArchiveAsync())?.Id) is not { } archive)
{ {
_shell.Notify(Loc.L("Errors.Sync.NoArchive")); _shell.Notify(Loc.L("Errors.Sync.NoArchive"), isError: true);
return; return;
} }
await service.EnqueueDownloadAsync(engine, server, entry.Id, entry.Title, SyncDownloadMode.Originals, archive); await service.EnqueueDownloadAsync(engine, server, entry.Id, entry.Title, SyncDownloadMode.Originals, archive);
@@ -372,7 +372,7 @@ public sealed class SyncTableViewModel : ObservableObject, IDisposable
catch (SyncConflictChangedException ex) catch (SyncConflictChangedException ex)
{ {
// One side changed after the choice was shown: the row now shows the fresh content. // One side changed after the choice was shown: the row now shows the fresh content.
_shell.Notify(ex.Message); _shell.Notify(ex.Message, isError: true);
} }
} }
+6 -2
View File
@@ -257,8 +257,11 @@ public sealed class ShellViewModel : LocalizedViewModel
if (e.PropertyName is nameof(SectionViewModel.Title) or "" or null) OnPropertyChanged(nameof(WindowTitle)); if (e.PropertyName is nameof(SectionViewModel.Title) or "" or null) OnPropertyChanged(nameof(WindowTitle));
} }
/// <summary>A one-line notice with one action (job done, update available).</summary> /// <summary>
public void Notify(string title, string? message = null, string? actionText = null, string? actionToolTip = null, Action? action = null) => /// A one-line notice with one action (job done, update available). <paramref name="isError"/> marks something that
/// did not happen or failed: screen readers then say it at once instead of after what they are reading.
/// </summary>
public void Notify(string title, string? message = null, string? actionText = null, string? actionToolTip = null, Action? action = null, bool isError = false) =>
ShowToast(new Toast ShowToast(new Toast
{ {
Title = title, Title = title,
@@ -266,6 +269,7 @@ public sealed class ShellViewModel : LocalizedViewModel
ActionText = actionText, ActionText = actionText,
ActionToolTip = actionToolTip, ActionToolTip = actionToolTip,
ActionCommand = action is null ? null : new RelayCommand(action), ActionCommand = action is null ? null : new RelayCommand(action),
IsError = isError,
}); });
/// <summary>Errors are one sentence saying what happened plus one action (BRIEF §0.2 rule 6); the details go to the log.</summary> /// <summary>Errors are one sentence saying what happened plus one action (BRIEF §0.2 rule 6); the details go to the log.</summary>
+7 -5
View File
@@ -346,7 +346,7 @@ public sealed class MainViewModel : LocalizedViewModel
if (paths.Count == 0) return; if (paths.Count == 0) return;
if (_target == UploadTargetMode.Sequence && SelectedSequence is null) if (_target == UploadTargetMode.Sequence && SelectedSequence is null)
{ {
ShowToast(Loc.L("Uploader.Toast.ChooseSequence")); ShowToast(Loc.L("Uploader.Toast.ChooseSequence"), isError: true);
return; return;
} }
var found = await Task.Run(() => PhotoScanner.Scan(paths)); var found = await Task.Run(() => PhotoScanner.Scan(paths));
@@ -394,7 +394,7 @@ public sealed class MainViewModel : LocalizedViewModel
public void ReportError(Exception ex) public void ReportError(Exception ex)
{ {
Log.Error("ui", "Operation failed", ex); Log.Error("ui", "Operation failed", ex);
ShowToast(Loc.L("Errors.Unexpected"), Loc.L("Common.OpenLogs"), Loc.L("Tooltips.Common.OpenLogs"), new RelayCommand(OpenLogs)); ShowToast(Loc.L("Errors.Unexpected"), Loc.L("Common.OpenLogs"), Loc.L("Tooltips.Common.OpenLogs"), new RelayCommand(OpenLogs), isError: true);
} }
public void TogglePause() public void TogglePause()
@@ -574,7 +574,8 @@ public sealed class MainViewModel : LocalizedViewModel
/// <summary>One sentence plus one action (BRIEF §0.2 rule 6): "Sign in" takes the user to the password box.</summary> /// <summary>One sentence plus one action (BRIEF §0.2 rule 6): "Sign in" takes the user to the password box.</summary>
private void OnSessionEnded(object? sender, ServerProblem problem) => private void OnSessionEnded(object? sender, ServerProblem problem) =>
ShowToast(Loc.L(problem == ServerProblem.CertificateChanged ? "Uploader.Toast.CertificateChanged" : "Uploader.Toast.SignedOut"), ShowToast(Loc.L(problem == ServerProblem.CertificateChanged ? "Uploader.Toast.CertificateChanged" : "Uploader.Toast.SignedOut"),
Loc.L("Uploader.Connect.SignIn"), Loc.L("Tooltips.Uploader.SignIn"), new RelayCommand(() => SignInRequested?.Invoke(this, EventArgs.Empty))); Loc.L("Uploader.Connect.SignIn"), Loc.L("Tooltips.Uploader.SignIn"), new RelayCommand(() => SignInRequested?.Invoke(this, EventArgs.Empty)),
isError: true);
private void OnDrained(object? sender, EventArgs e) private void OnDrained(object? sender, EventArgs e)
{ {
@@ -585,8 +586,9 @@ public sealed class MainViewModel : LocalizedViewModel
if (confirmed > 0) UploadsCompleted?.Invoke(confirmed); if (confirmed > 0) UploadsCompleted?.Invoke(confirmed);
} }
private void ShowToast(string title, string? actionText = null, string? actionToolTip = null, ICommand? action = null) => /// <summary>One sentence and at most one action; <paramref name="isError"/> marks a failure or refusal, which screen readers say at once.</summary>
PendingToasts.Add(new Toast { Title = title, ActionText = actionText, ActionToolTip = actionToolTip, ActionCommand = action }); private void ShowToast(string title, string? actionText = null, string? actionToolTip = null, ICommand? action = null, bool isError = false) =>
PendingToasts.Add(new Toast { Title = title, ActionText = actionText, ActionToolTip = actionToolTip, ActionCommand = action, IsError = isError });
private void OpenLogs() private void OpenLogs()
{ {