From b92ef7922da47774fceba41e6f73de6e3babe9b4 Mon Sep 17 00:00:00 2001 From: Josh Date: Mon, 3 Feb 2025 03:20:26 -0800 Subject: [PATCH] Add Notify overload that accepts a Timespan for duration, for improved clarity (#1936) --- Radzen.Blazor/NotificationService.cs | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/Radzen.Blazor/NotificationService.cs b/Radzen.Blazor/NotificationService.cs index 34f704e31c7..427b08e0416 100644 --- a/Radzen.Blazor/NotificationService.cs +++ b/Radzen.Blazor/NotificationService.cs @@ -8,7 +8,7 @@ namespace Radzen { /// - /// Class NotificationService. Contains various methods with options to open notifications. + /// Class NotificationService. Contains various methods with options to open notifications. /// Should be added as scoped service in the application services and RadzenNotification should be added in application main layout. /// /// @@ -50,6 +50,20 @@ public void Notify(NotificationMessage message) /// The detail. /// The duration. /// The click event. + public void Notify(NotificationSeverity severity, string summary, + string detail, TimeSpan duration, Action click = null) + { + Notify(severity, summary, detail, duration.TotalMilliseconds, click); + } + + /// + /// Notifies the specified severity. + /// + /// The severity. + /// The summary. + /// The detail. + /// The duration, default of 3 seconds. + /// The click event. /// If true, then the notification will be closed when clicked on. /// Used to store a custom payload that can be retreived later in the click event handler. /// Action to be executed on close. @@ -108,7 +122,7 @@ public class NotificationMessage : IEquatable /// Gets or sets the click event. /// /// This event handler is called when the notification is clicked on. - public Action Click { get; set; } + public Action Click { get; set; } /// /// Get or set the event for when the notification is closed /// @@ -146,12 +160,12 @@ public class NotificationMessage : IEquatable public bool Equals(NotificationMessage other) { if(other == null) return false; - + if(object.ReferenceEquals(this, other)) return true; - return this.Severity == other.Severity - && this.Summary == other.Summary - && this.Detail == other.Detail + return this.Severity == other.Severity + && this.Summary == other.Summary + && this.Detail == other.Detail && this.Duration == other.Duration && this.Style == other.Style && this.Click == other.Click