fix(app): notification clicks run only what the toast names, batches speak once, warnings get badges
- Toast.RunsFromNotification: a click on a Windows notification restores the window and runs the toast's
action only when the toast opts in (card detected: Import; interrupted import: Resume; job finished: Open;
navigation to Import or Jobs) and it is the only notification shown since the icon appeared. Cancel, Undo
and Retry stay in the window, and the notification text no longer offers them.
- Job endings are coalesced: finished jobs of one kind wait until no job of that kind the user waits for is
queued or running, then one toast says how many finished ("12 jobs finished", action Jobs); failures of one
update share one toast. Server > Upload all no longer raises one toast and one notification per sequence.
- Every failure that is not upkeep (scan, thumbnails, proxies, light analysis) is announced, including move,
adopt and user downloads; finished moves and adoptions are announced too.
- Rail badges: Library counts the sequences with warnings (the Warnings filter), refreshed after analyses;
Archive counts the index health lines that need attention.
- Tests: the balloon click path, the --minimized restore to a saved maximised window, batch and failure
coalescing, and the new badges.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012iLMBNwBE2GnphAsu4cjaC
This commit is contained in:
15 files changed
+438
-64
No files matched your search
@@ -137,6 +137,13 @@ public sealed class JobListModel
|
||||
|
||||
public int QueuedCount => _entries.Values.Count(e => e.State == JobState.Queued);
|
||||
|
||||
/// <summary>
|
||||
/// A job of <paramref name="kind"/> that the user waits for (not background work) is queued or running. Paused jobs
|
||||
/// do not count: they wait for the user, or for an unmetered network, not for the queue.
|
||||
/// </summary>
|
||||
public bool IsBusy(JobKind kind) =>
|
||||
_entries.Values.Any(e => e.Job.Kind == kind && e.Job.Priority != JobPriority.Background && e.State is JobState.Queued or JobState.Running);
|
||||
|
||||
/// <summary>Same order as <c>JobRepository.ClaimNextAsync</c>: priority descending, then creation time and id.</summary>
|
||||
public static bool ClaimsBefore(Job a, Job b) =>
|
||||
a.Priority != b.Priority ? a.Priority > b.Priority : a.Created != b.Created ? a.Created < b.Created : a.Id.CompareTo(b.Id) < 0;
|
||||
|
||||
@@ -14,7 +14,8 @@ public enum JobNotice
|
||||
/// Which job endings raise a toast (BRIEF §12.1 "toasts for job completion"): the long operations the user asked for
|
||||
/// end with one toast, whichever screen started them. Background work (thumbnails, proxies, light analysis, the
|
||||
/// analysis queued after an import) and scans (the archive is rescanned every 10 minutes) end silently; an import
|
||||
/// has its own toast when it ends well, and the Import screen holds its retry. Cancelled jobs were stopped on purpose.
|
||||
/// has its own toast when it ends well, and a download shows on its Library card and Server row. Every other failure
|
||||
/// is said. Cancelled jobs were stopped on purpose.
|
||||
/// </summary>
|
||||
public static class JobNotices
|
||||
{
|
||||
@@ -29,11 +30,69 @@ public static class JobNotices
|
||||
return job.State switch
|
||||
{
|
||||
JobState.Done when Announces(job.Kind) => JobNotice.Done,
|
||||
JobState.Failed when Announces(job.Kind) || job.Kind == JobKind.Import => JobNotice.Failed,
|
||||
JobState.Failed when !IsUpkeep(job.Kind) => JobNotice.Failed,
|
||||
_ => JobNotice.None,
|
||||
};
|
||||
}
|
||||
|
||||
private static bool Announces(JobKind kind) =>
|
||||
kind is JobKind.Render or JobKind.DeepAnalyse or JobKind.Verify or JobKind.Rebuild or JobKind.Maintenance or JobKind.UploadCommit;
|
||||
kind is JobKind.Render or JobKind.DeepAnalyse or JobKind.Verify or JobKind.Rebuild or JobKind.Maintenance or JobKind.UploadCommit
|
||||
or JobKind.Move or JobKind.Adopt;
|
||||
|
||||
/// <summary>Work that keeps the index and its previews current: the next run repeats it, the Archive screen shows what is missing.</summary>
|
||||
private static bool IsUpkeep(JobKind kind) =>
|
||||
kind is JobKind.Scan or JobKind.Thumbs or JobKind.Proxies or JobKind.LightAnalyse;
|
||||
}
|
||||
|
||||
/// <summary>Endings said in one toast: one job, or several of a batch.</summary>
|
||||
public sealed record JobEnding(JobNotice Notice, IReadOnlyList<Job> Jobs);
|
||||
|
||||
/// <summary>
|
||||
/// Job endings waiting for their toast, so that a batch speaks once (Server › Upload all queues one upload per
|
||||
/// sequence): finished jobs of one kind wait until no job of that kind the user waits for is queued or running, then
|
||||
/// one toast says how many finished; failures are said at the end of the update that brought them, together when
|
||||
/// several failed at once. WPF-free; feed it on the UI thread.
|
||||
/// </summary>
|
||||
public sealed class JobEndings
|
||||
{
|
||||
private readonly SortedDictionary<JobKind, List<Job>> _done = [];
|
||||
private readonly List<Job> _failed = [];
|
||||
|
||||
/// <summary>Finished jobs still waiting for the rest of their kind (tests).</summary>
|
||||
public int Waiting => _done.Values.Sum(l => l.Count);
|
||||
|
||||
public void Add(JobNotice notice, Job job)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(job);
|
||||
if (notice == JobNotice.Failed)
|
||||
{
|
||||
_failed.Add(job);
|
||||
}
|
||||
else if (notice == JobNotice.Done)
|
||||
{
|
||||
if (!_done.TryGetValue(job.Kind, out var jobs)) _done[job.Kind] = jobs = [];
|
||||
jobs.Add(job);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The toasts due now: the failures added since the last call, then each finished kind that <paramref name="busy"/>
|
||||
/// no longer reports as queued or running. What is returned is forgotten.
|
||||
/// </summary>
|
||||
public IReadOnlyList<JobEnding> Take(Func<JobKind, bool> busy)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(busy);
|
||||
var due = new List<JobEnding>();
|
||||
if (_failed.Count > 0)
|
||||
{
|
||||
due.Add(new JobEnding(JobNotice.Failed, [.. _failed]));
|
||||
_failed.Clear();
|
||||
}
|
||||
foreach (var kind in _done.Keys.Where(k => !busy(k)).ToList())
|
||||
{
|
||||
due.Add(new JobEnding(JobNotice.Done, _done[kind]));
|
||||
_done.Remove(kind);
|
||||
}
|
||||
return due;
|
||||
}
|
||||
}
|
||||
@@ -484,6 +484,8 @@ public sealed class ArchiveViewModel : SectionViewModel
|
||||
_ => null,
|
||||
})),
|
||||
];
|
||||
// The rail badge counts the health lines that need attention (BRIEF §12.1 "badge counts (warnings, …)").
|
||||
Badge = Health.Count(h => !h.IsOk);
|
||||
}
|
||||
|
||||
private static IReadOnlyList<ChartItem> Bars(IReadOnlyList<BarValue> values) =>
|
||||
|
||||
@@ -1399,7 +1399,7 @@ public sealed class ImportViewModel : SectionViewModel
|
||||
if (_phase == ImportPhase.Failed && _jobId is not null && _jobSourceKey == device.Identity)
|
||||
{
|
||||
Shell.Notify(Loc.L("Import.Toast.Inserted", source.Title), Loc.L("Import.Toast.ResumeMessage"), Loc.L("Import.Toast.Resume"),
|
||||
Loc.L("Tooltips.Import.Resume"), () => RetryCommand.Execute(null));
|
||||
Loc.L("Tooltips.Import.Resume"), () => RetryCommand.Execute(null), runsFromNotification: true);
|
||||
return;
|
||||
}
|
||||
if (_phase == ImportPhase.Running) return;
|
||||
@@ -1425,6 +1425,8 @@ public sealed class ImportViewModel : SectionViewModel
|
||||
SelectSource(device.Identity);
|
||||
Shell.Navigate(SectionKey.Import);
|
||||
}),
|
||||
// BRIEF §12.4: the Windows notification "Card X detected — Import" opens the card on Import.
|
||||
RunsFromNotification = true,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -62,6 +62,7 @@ public sealed class JobsViewModel : SectionViewModel
|
||||
private readonly JobUpdateBuffer _buffer = new();
|
||||
private readonly Dictionary<Guid, JobRowViewModel> _rows = [];
|
||||
private readonly HashSet<Guid> _unseenFailures = [];
|
||||
private readonly JobEndings _endings = new();
|
||||
private readonly JobActions _actions;
|
||||
private CoalescingThrottle? _throttle;
|
||||
private IJobQueue? _queue;
|
||||
@@ -227,6 +228,7 @@ public sealed class JobsViewModel : SectionViewModel
|
||||
Follow(before, job);
|
||||
}
|
||||
foreach (var p in progress) _model.Apply(p);
|
||||
foreach (var ending in _endings.Take(_model.IsBusy)) Shell.ShowToast(ToastFor(ending));
|
||||
SyncRows();
|
||||
UpdateShell();
|
||||
}
|
||||
@@ -241,43 +243,72 @@ public sealed class JobsViewModel : SectionViewModel
|
||||
|
||||
/// <summary>
|
||||
/// A change the engine reported (these are live, never pages read again): a failure counts on the rail until this
|
||||
/// screen is opened, and a long operation that ends says so in a toast with one action (BRIEF §12.1, §0.2 rule 6).
|
||||
/// screen is opened, and a long operation that ends is announced at the end of the flush (<see cref="JobEndings"/>).
|
||||
/// </summary>
|
||||
private void Follow(JobState? before, Job job)
|
||||
{
|
||||
if (job.State != JobState.Failed) _unseenFailures.Remove(job.Id);
|
||||
else if (before != JobState.Failed && !IsSelected) _unseenFailures.Add(job.Id);
|
||||
var notice = JobNotices.For(before, job);
|
||||
if (notice == JobNotice.None || (notice == JobNotice.Done && EditorAnnounces(job))) return;
|
||||
Shell.ShowToast(notice == JobNotice.Done
|
||||
? new Toast
|
||||
if (notice == JobNotice.Done && EditorAnnounces(job)) return;
|
||||
_endings.Add(notice, job);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The toast of a job that ended, with one action (BRIEF §12.1, §0.2 rule 6). Several endings at once (a batch
|
||||
/// finished, or failed together) say how many and lead to this screen. Clicking the Windows notification of a
|
||||
/// toast opens what it names; a retry waits until the user has seen why the job failed.
|
||||
/// </summary>
|
||||
private Toast ToastFor(JobEnding ending)
|
||||
{
|
||||
var job = ending.Jobs[0];
|
||||
var failed = ending.Notice == JobNotice.Failed;
|
||||
if (ending.Jobs.Count > 1)
|
||||
{
|
||||
return new Toast
|
||||
{
|
||||
Title = Loc.Plural(failed ? "Shell.Job.FailedPlural" : "Shell.Job.DonePlural", ending.Jobs.Count),
|
||||
Message = ending.Jobs.All(j => j.Kind == job.Kind) ? JobText.Kind(job.Kind) : null,
|
||||
ActionText = Loc.L("Shell.Nav.Jobs"),
|
||||
ActionToolTip = Loc.L("Tooltips.Nav.Jobs"),
|
||||
ActionCommand = new RelayCommand(() => Shell.Navigate(SectionKey.Jobs)),
|
||||
IsError = failed,
|
||||
RunsFromNotification = true,
|
||||
};
|
||||
}
|
||||
if (!failed)
|
||||
{
|
||||
return new Toast
|
||||
{
|
||||
Title = Loc.L("Shell.Job.Done"),
|
||||
Message = JobText.Name(job),
|
||||
ActionText = Loc.L("Jobs.Action.Open"),
|
||||
ActionToolTip = Loc.L("Tooltips.Jobs.Open"),
|
||||
ActionCommand = new AsyncRelayCommand(() => OpenTargetAsync(job)),
|
||||
RunsFromNotification = true,
|
||||
};
|
||||
}
|
||||
return job.Kind == JobKind.Import
|
||||
// The Import screen resumes an import with its plan and card; it holds the retry.
|
||||
? new Toast
|
||||
{
|
||||
Title = Loc.L("Shell.Job.Failed"),
|
||||
Message = JobText.Name(job),
|
||||
ActionText = Loc.L("Shell.Nav.Import"),
|
||||
ActionToolTip = Loc.L("Tooltips.Nav.Import"),
|
||||
ActionCommand = new RelayCommand(() => Shell.Navigate(SectionKey.Import)),
|
||||
IsError = true,
|
||||
RunsFromNotification = true,
|
||||
}
|
||||
: job.Kind == JobKind.Import
|
||||
// The Import screen resumes an import with its plan and card; it holds the retry.
|
||||
? new Toast
|
||||
{
|
||||
Title = Loc.L("Shell.Job.Failed"),
|
||||
Message = JobText.Name(job),
|
||||
ActionText = Loc.L("Shell.Nav.Import"),
|
||||
ActionToolTip = Loc.L("Tooltips.Nav.Import"),
|
||||
ActionCommand = new RelayCommand(() => Shell.Navigate(SectionKey.Import)),
|
||||
IsError = true,
|
||||
}
|
||||
: new Toast
|
||||
{
|
||||
Title = Loc.L("Shell.Job.Failed"),
|
||||
Message = JobText.Name(job),
|
||||
ActionText = Loc.L("Jobs.Action.Retry"),
|
||||
ActionToolTip = Loc.L("Tooltips.Jobs.Retry"),
|
||||
ActionCommand = new AsyncRelayCommand(() => _queue?.ResumeAsync(job.Id) ?? Task.CompletedTask),
|
||||
IsError = true,
|
||||
});
|
||||
: new Toast
|
||||
{
|
||||
Title = Loc.L("Shell.Job.Failed"),
|
||||
Message = JobText.Name(job),
|
||||
ActionText = Loc.L("Jobs.Action.Retry"),
|
||||
ActionToolTip = Loc.L("Tooltips.Jobs.Retry"),
|
||||
ActionCommand = new AsyncRelayCommand(() => _queue?.ResumeAsync(job.Id) ?? Task.CompletedTask),
|
||||
IsError = true,
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>A finished render of the sequence open in the editor: the editor says it, with its output file.</summary>
|
||||
|
||||
@@ -700,6 +700,7 @@ public sealed class LibraryViewModel : SectionViewModel
|
||||
_hasArchive = (await _db.Archives.ListAsync()).Count > 0;
|
||||
Shell.SetLibraryTotals(stats.Sequences, stats.Photos, stats.Bytes);
|
||||
_localStats = stats;
|
||||
await CountWarningsAsync();
|
||||
|
||||
_suppressReload = true;
|
||||
var tag = _tag.Value;
|
||||
@@ -1025,6 +1026,8 @@ public sealed class LibraryViewModel : SectionViewModel
|
||||
if (job.Kind is JobKind.Scan or JobKind.Rebuild or JobKind.Import or JobKind.Adopt or JobKind.Move or JobKind.UploadCommit
|
||||
|| SyncService.TransferKind(job) is SyncTransferKind.DownloadOriginals or SyncTransferKind.GetExports)
|
||||
await RefreshAsync();
|
||||
else if (job.Kind is JobKind.LightAnalyse or JobKind.DeepAnalyse)
|
||||
await CountWarningsAsync();
|
||||
}
|
||||
catch (DatabaseException ex)
|
||||
{
|
||||
@@ -1032,6 +1035,15 @@ public sealed class LibraryViewModel : SectionViewModel
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The rail badge counts the sequences of this PC with warnings (BRIEF §12.1 "badge counts (warnings, …)"), the
|
||||
/// ones the Warnings filter shows; analyses change it.
|
||||
/// </summary>
|
||||
private async Task CountWarningsAsync()
|
||||
{
|
||||
if (_db is not null) Badge = await _db.Sequences.CountAsync(new SequenceQuery { WithStatus = SequenceStatus.HasWarnings });
|
||||
}
|
||||
|
||||
/// <summary>Open: the editor for a sequence here; for a remote card, with proxies (fetched first when this PC has none).</summary>
|
||||
private async Task OpenAsync(SequenceItem item)
|
||||
{
|
||||
|
||||
@@ -43,6 +43,17 @@ public partial class MainWindow : TitanoWindow
|
||||
internal static bool StartsMinimized(IReadOnlyList<string> arguments) =>
|
||||
arguments.Any(a => a.Equals(RunKeyStartWithWindows.MinimizedOption, StringComparison.OrdinalIgnoreCase));
|
||||
|
||||
/// <summary>Minimised until the user opens it; that first restore brings back the saved state (maximised or not).</summary>
|
||||
internal void WaitMinimized(bool maximized)
|
||||
{
|
||||
WindowState = WindowState.Minimized;
|
||||
_restoreTo = maximized ? WindowState.Maximized : WindowState.Normal;
|
||||
}
|
||||
|
||||
/// <summary>The maximised flag to save: a window started minimised and never opened keeps the state it would come back to.</summary>
|
||||
internal static bool SavesMaximized(WindowState state, WindowState? restoreTo) =>
|
||||
state == WindowState.Maximized || (state == WindowState.Minimized && restoreTo == WindowState.Maximized);
|
||||
|
||||
/// <summary>The first restore of a window started minimised brings back the saved maximised state.</summary>
|
||||
protected override void OnStateChanged(EventArgs e)
|
||||
{
|
||||
@@ -101,11 +112,7 @@ public partial class MainWindow : TitanoWindow
|
||||
if (_shell.Services.Environment.IsCapture) return;
|
||||
var p = _shell.Services.Settings.Window;
|
||||
var maximized = p?.Maximized == true;
|
||||
if (StartsMinimized(Environment.GetCommandLineArgs()))
|
||||
{
|
||||
WindowState = WindowState.Minimized;
|
||||
_restoreTo = maximized ? WindowState.Maximized : WindowState.Normal;
|
||||
}
|
||||
if (StartsMinimized(Environment.GetCommandLineArgs())) WaitMinimized(maximized);
|
||||
if (p is null || p.Width < MinWidth || p.Height < MinHeight) return;
|
||||
var virtualScreen = new Rect(SystemParameters.VirtualScreenLeft, SystemParameters.VirtualScreenTop, SystemParameters.VirtualScreenWidth, SystemParameters.VirtualScreenHeight);
|
||||
var rect = new Rect(p.Left, p.Top, p.Width, p.Height);
|
||||
@@ -128,8 +135,7 @@ public partial class MainWindow : TitanoWindow
|
||||
Top = b.Top,
|
||||
Width = b.Width,
|
||||
Height = b.Height,
|
||||
// Started minimised and never opened: the saved state stays the one it would have been restored to.
|
||||
Maximized = WindowState == WindowState.Maximized || (WindowState == WindowState.Minimized && _restoreTo == WindowState.Maximized),
|
||||
Maximized = SavesMaximized(WindowState, _restoreTo),
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -9,8 +9,10 @@ namespace Titano.App.Shell;
|
||||
/// Windows notifications for the toasts nobody would see (BRIEF §12.1 "optional OS toast when minimised", §12.4 "Card
|
||||
/// X detected — Import"): while the main window is minimised, hidden or behind another program, every toast also goes
|
||||
/// to a tray balloon, which Windows 10/11 shows as a notification, when Settings › General allows it. Clicking it
|
||||
/// brings the window back and runs the toast's action. The tray icon exists only while such a notification can be
|
||||
/// clicked: it goes once a window of Titano is active again. Create, use and dispose it on the UI thread.
|
||||
/// brings the window back; it also runs the toast's action when the toast allows it
|
||||
/// (<see cref="Toast.RunsFromNotification"/>) and it is the only notification shown, since Windows does not say which
|
||||
/// of several was clicked. The tray icon exists only while such a notification can be clicked: it goes once a window
|
||||
/// of Titano is active again. Create, use and dispose it on the UI thread.
|
||||
/// </summary>
|
||||
public sealed class OsNotifications : IDisposable
|
||||
{
|
||||
@@ -21,6 +23,7 @@ public sealed class OsNotifications : IDisposable
|
||||
private readonly Action<Toast> _dismiss;
|
||||
private TrayIcon? _tray;
|
||||
private Toast? _latest;
|
||||
private int _shown;
|
||||
private bool _disposed;
|
||||
|
||||
/// <param name="window">The main window, restored by a click.</param>
|
||||
@@ -44,6 +47,7 @@ public sealed class OsNotifications : IDisposable
|
||||
if (_disposed || !_enabled() || !IsUnseen(_window.WindowState, _window.IsVisible, AnyWindowActive())) return false;
|
||||
_tray ??= new TrayIcon(Loc.L("Shell.AppName"), Menu, OnMenu, Restore, OnBalloonClicked);
|
||||
_latest = toast;
|
||||
_shown++;
|
||||
_tray.ShowBalloon(toast.Title, BalloonText(toast), toast.IsError);
|
||||
return true;
|
||||
}
|
||||
@@ -60,16 +64,31 @@ public sealed class OsNotifications : IDisposable
|
||||
state == WindowState.Minimized || !isVisible || !anyWindowActive;
|
||||
|
||||
/// <summary>
|
||||
/// The notification's text: the toast's message, then its action ("Import"), which a click on it runs; the title
|
||||
/// alone when there is neither (Windows needs a text to show a notification at all).
|
||||
/// The notification's text: the toast's message, then the action a click on it runs ("Import"); the title alone
|
||||
/// when there is neither (Windows needs a text to show a notification at all). An action a click does not run
|
||||
/// waits in the window and is not offered here.
|
||||
/// </summary>
|
||||
public static string BalloonText(Toast toast)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(toast);
|
||||
var lines = new[] { toast.Message, toast.ActionText }.Where(l => !string.IsNullOrWhiteSpace(l));
|
||||
var lines = new[] { toast.Message, toast.RunsFromNotification ? toast.ActionText : null }.Where(l => !string.IsNullOrWhiteSpace(l));
|
||||
return string.Join(Environment.NewLine, lines) is { Length: > 0 } text ? text : toast.Title;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A notification was clicked: the window comes back, and the toast's action runs when the toast allows it and
|
||||
/// no other notification was shown since the icon appeared (Windows does not say which one was clicked).
|
||||
/// </summary>
|
||||
internal void OnBalloonClicked()
|
||||
{
|
||||
var toast = _shown == 1 ? _latest : null;
|
||||
_latest = null;
|
||||
Restore();
|
||||
if (toast is not { RunsFromNotification: true, ActionCommand: { } command } || !command.CanExecute(null)) return;
|
||||
command.Execute(null);
|
||||
_dismiss(toast);
|
||||
}
|
||||
|
||||
private static bool AnyWindowActive() => Application.Current?.Windows.OfType<Window>().Any(w => w.IsActive) ?? false;
|
||||
|
||||
private IReadOnlyList<TrayMenuItem> Menu() => [new(MenuShow, Loc.L("Shell.Tray.Show"))];
|
||||
@@ -87,16 +106,6 @@ public sealed class OsNotifications : IDisposable
|
||||
_window.Activate();
|
||||
}
|
||||
|
||||
private void OnBalloonClicked()
|
||||
{
|
||||
var toast = _latest;
|
||||
_latest = null;
|
||||
Restore();
|
||||
if (toast?.ActionCommand is not { } command || !command.CanExecute(null)) return;
|
||||
command.Execute(null);
|
||||
_dismiss(toast);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Back in front: the notifications have done their job. The icon goes after the current message, since activation
|
||||
/// may come from a click the icon's own window is still handling, unless the window went to the background again.
|
||||
@@ -113,6 +122,7 @@ public sealed class OsNotifications : IDisposable
|
||||
private void RemoveIcon()
|
||||
{
|
||||
_latest = null;
|
||||
_shown = 0;
|
||||
_tray?.Dispose();
|
||||
_tray = null;
|
||||
}
|
||||
|
||||
@@ -291,8 +291,10 @@ public sealed class ShellViewModel : LocalizedViewModel
|
||||
/// <summary>
|
||||
/// 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.
|
||||
/// <paramref name="runsFromNotification"/>: a click on its Windows notification also runs the action (<see cref="Toast.RunsFromNotification"/>).
|
||||
/// </summary>
|
||||
public void Notify(string title, string? message = null, string? actionText = null, string? actionToolTip = null, Action? action = null, bool isError = false) =>
|
||||
public void Notify(string title, string? message = null, string? actionText = null, string? actionToolTip = null, Action? action = null, bool isError = false,
|
||||
bool runsFromNotification = false) =>
|
||||
ShowToast(new Toast
|
||||
{
|
||||
Title = title,
|
||||
@@ -301,6 +303,7 @@ public sealed class ShellViewModel : LocalizedViewModel
|
||||
ActionToolTip = actionToolTip,
|
||||
ActionCommand = action is null ? null : new RelayCommand(action),
|
||||
IsError = isError,
|
||||
RunsFromNotification = runsFromNotification,
|
||||
});
|
||||
|
||||
/// <summary>Errors are one sentence saying what happened plus one action (BRIEF §0.2 rule 6); the details go to the log.</summary>
|
||||
|
||||
@@ -22,6 +22,13 @@ public sealed class Toast : ObservableObject
|
||||
|
||||
/// <summary>Something failed: screen readers say it at once, ahead of other notices (assertive, not polite).</summary>
|
||||
public bool IsError { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// A click on the toast's Windows notification also runs its action (it opens what the toast names). Off by
|
||||
/// default: people click a notification to bring the window back, so a Cancel, Undo or Retry there would act
|
||||
/// before they have read why.
|
||||
/// </summary>
|
||||
public bool RunsFromNotification { get; init; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in new issue
Block a user