diff --git a/src/Titano.App/Import/ImportResultViewModel.cs b/src/Titano.App/Import/ImportResultViewModel.cs
index bea85506..04f65e89 100644
--- a/src/Titano.App/Import/ImportResultViewModel.cs
+++ b/src/Titano.App/Import/ImportResultViewModel.cs
@@ -177,7 +177,7 @@ public sealed class ImportResultViewModel : LocalizedViewModel
catch (Exception ex) when (ex is IOException or UnauthorizedAccessException or DatabaseException)
{
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
{
@@ -212,7 +212,7 @@ public sealed class ImportResultViewModel : LocalizedViewModel
catch (Exception ex) when (ex is IOException or UnauthorizedAccessException)
{
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
{
@@ -263,12 +263,12 @@ public sealed class ImportResultViewModel : LocalizedViewModel
if (!unchanged)
{
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;
}
var outcome = _shell.Services.Devices.Format(device);
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);
}
/// The first files that were never imported, one per line.
@@ -286,7 +286,7 @@ public sealed class ImportResultViewModel : LocalizedViewModel
try
{
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);
}
finally
diff --git a/src/Titano.App/Infrastructure/ArchiveSetup.cs b/src/Titano.App/Infrastructure/ArchiveSetup.cs
index 15b3672c..0533f67a 100644
--- a/src/Titano.App/Infrastructure/ArchiveSetup.cs
+++ b/src/Titano.App/Infrastructure/ArchiveSetup.cs
@@ -56,7 +56,7 @@ public static class ArchiveActions
or Data.DatabaseException)
{
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;
}
}
diff --git a/src/Titano.App/Sections/ArchiveViewModel.cs b/src/Titano.App/Sections/ArchiveViewModel.cs
index c47e089e..ac4a701f 100644
--- a/src/Titano.App/Sections/ArchiveViewModel.cs
+++ b/src/Titano.App/Sections/ArchiveViewModel.cs
@@ -900,5 +900,6 @@ public sealed class ArchiveViewModel : SectionViewModel
/// An action stopped: what stopped, why in one sentence, and Retry to run it again (BRIEF §0.2 rule 6).
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);
}
diff --git a/src/Titano.App/Sections/SequenceViewModel.cs b/src/Titano.App/Sections/SequenceViewModel.cs
index b4c4e186..63fb5fc4 100644
--- a/src/Titano.App/Sections/SequenceViewModel.cs
+++ b/src/Titano.App/Sections/SequenceViewModel.cs
@@ -197,7 +197,7 @@ public sealed class SequenceViewModel : SectionViewModel
break;
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.Navigate(SectionKey.Jobs));
+ () => Shell.Navigate(SectionKey.Jobs), isError: true);
break;
}
}
diff --git a/src/Titano.App/Sections/SettingsViewModel.cs b/src/Titano.App/Sections/SettingsViewModel.cs
index 47b7b01f..0e1661ab 100644
--- a/src/Titano.App/Sections/SettingsViewModel.cs
+++ b/src/Titano.App/Sections/SettingsViewModel.cs
@@ -661,7 +661,7 @@ public sealed class SettingsViewModel : SectionViewModel
Shell.Services.Thumbnails?.Clear();
if (!CacheStore.IsOwned(folder))
{
- Shell.Notify(Loc.L("Settings.Storage.NotOwned"));
+ Shell.Notify(Loc.L("Settings.Storage.NotOwned"), isError: true);
return;
}
var freed = await Task.Run(() => CacheStore.Clear(folder));
@@ -776,7 +776,7 @@ public sealed class SettingsViewModel : SectionViewModel
}
if (imported is null)
{
- Shell.Notify(Loc.L("Errors.Settings.Import"));
+ Shell.Notify(Loc.L("Errors.Settings.Import"), isError: true);
return;
}
// Everything but the session, the window and the first-run flag.
diff --git a/src/Titano.App/Sections/WelcomeViewModel.cs b/src/Titano.App/Sections/WelcomeViewModel.cs
index 3276e6e0..e452bd4e 100644
--- a/src/Titano.App/Sections/WelcomeViewModel.cs
+++ b/src/Titano.App/Sections/WelcomeViewModel.cs
@@ -204,7 +204,7 @@ public sealed class WelcomeViewModel : LocalizedViewModel
case WelcomeChoice.LocalArchive:
if (ArchiveLocations.Validate(LocalRoot) is { } problem)
{
- _shell.Notify(problem);
+ _shell.Notify(problem, isError: true);
return;
}
if (!await ArchiveActions.TryAsync(_shell, s => s.CreateAsync(LocalRoot))) return;
diff --git a/src/Titano.App/Server/SyncTableViewModel.cs b/src/Titano.App/Server/SyncTableViewModel.cs
index 2b1cc56c..4dba9334 100644
--- a/src/Titano.App/Server/SyncTableViewModel.cs
+++ b/src/Titano.App/Server/SyncTableViewModel.cs
@@ -317,7 +317,7 @@ public sealed class SyncTableViewModel : ObservableObject, IDisposable
case SyncAction.DownloadOriginals:
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;
}
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)
{
// 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);
}
}
diff --git a/src/Titano.App/Shell/ShellViewModel.cs b/src/Titano.App/Shell/ShellViewModel.cs
index 6a68c0e3..e53faa1a 100644
--- a/src/Titano.App/Shell/ShellViewModel.cs
+++ b/src/Titano.App/Shell/ShellViewModel.cs
@@ -257,8 +257,11 @@ public sealed class ShellViewModel : LocalizedViewModel
if (e.PropertyName is nameof(SectionViewModel.Title) or "" or null) OnPropertyChanged(nameof(WindowTitle));
}
- /// A one-line notice with one action (job done, update available).
- 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). marks something that
+ /// did not happen or failed: screen readers then say it at once instead of after what they are reading.
+ ///
+ public void Notify(string title, string? message = null, string? actionText = null, string? actionToolTip = null, Action? action = null, bool isError = false) =>
ShowToast(new Toast
{
Title = title,
@@ -266,6 +269,7 @@ public sealed class ShellViewModel : LocalizedViewModel
ActionText = actionText,
ActionToolTip = actionToolTip,
ActionCommand = action is null ? null : new RelayCommand(action),
+ IsError = isError,
});
/// Errors are one sentence saying what happened plus one action (BRIEF §0.2 rule 6); the details go to the log.
diff --git a/src/Titano.Uploader/Shell/MainViewModel.cs b/src/Titano.Uploader/Shell/MainViewModel.cs
index 8cd5465d..d7a24f4d 100644
--- a/src/Titano.Uploader/Shell/MainViewModel.cs
+++ b/src/Titano.Uploader/Shell/MainViewModel.cs
@@ -346,7 +346,7 @@ public sealed class MainViewModel : LocalizedViewModel
if (paths.Count == 0) return;
if (_target == UploadTargetMode.Sequence && SelectedSequence is null)
{
- ShowToast(Loc.L("Uploader.Toast.ChooseSequence"));
+ ShowToast(Loc.L("Uploader.Toast.ChooseSequence"), isError: true);
return;
}
var found = await Task.Run(() => PhotoScanner.Scan(paths));
@@ -394,7 +394,7 @@ public sealed class MainViewModel : LocalizedViewModel
public void ReportError(Exception 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()
@@ -574,7 +574,8 @@ public sealed class MainViewModel : LocalizedViewModel
/// One sentence plus one action (BRIEF §0.2 rule 6): "Sign in" takes the user to the password box.
private void OnSessionEnded(object? sender, ServerProblem problem) =>
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)
{
@@ -585,8 +586,9 @@ public sealed class MainViewModel : LocalizedViewModel
if (confirmed > 0) UploadsCompleted?.Invoke(confirmed);
}
- private void ShowToast(string title, string? actionText = null, string? actionToolTip = null, ICommand? action = null) =>
- PendingToasts.Add(new Toast { Title = title, ActionText = actionText, ActionToolTip = actionToolTip, ActionCommand = action });
+ /// One sentence and at most one action; marks a failure or refusal, which screen readers say at once.
+ 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()
{