Skip to content

Commit 4ed03d1

Browse files
committed
fix(core, framework): ensure guid always passed, deprecate old UpdateNotification method
1 parent e91fc58 commit 4ed03d1

File tree

5 files changed

+30
-8
lines changed

5 files changed

+30
-8
lines changed

ObservatoryCore/NativeNotification/NativePopup.cs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ public class NativePopup
99

1010
public NativePopup()
1111
{
12-
notifications = new();
12+
notifications = [];
1313
}
1414

1515
public Guid InvokeNativeNotification(NotificationArgs notificationArgs)
@@ -53,17 +53,19 @@ private void NotifyWindow_Closed(object? sender, EventArgs e)
5353

5454
public void CloseNotification(Guid guid)
5555
{
56-
if (notifications.ContainsKey(guid))
56+
if (notifications.TryGetValue(guid, out NotificationForm? value))
5757
{
58-
notifications[guid].Close();
58+
value.Close();
5959
}
6060
}
6161

62-
public void UpdateNotification(Guid guid, NotificationArgs notificationArgs)
62+
public void UpdateNotification(NotificationArgs notificationArgs)
6363
{
64-
if (notifications.ContainsKey(guid))
64+
var guid = notificationArgs.Guid
65+
?? throw new ArgumentNullException(nameof(notificationArgs), "Cannot update notification without Guid.");
66+
if (notifications.TryGetValue(guid, out NotificationForm? value))
6567
{
66-
notifications[guid].Update(notificationArgs);
68+
value.Update(notificationArgs);
6769
}
6870
}
6971

ObservatoryCore/ObservatoryCore.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
<PropertyGroup>
1414
<ProjectName>Elite Observatory Core</ProjectName>
15-
<VersionSuffix>1.2.7.$([System.DateTime]::UtcNow.DayOfYear.ToString().PadLeft(3, "0"))$([System.DateTime]::UtcNow.Hour)</VersionSuffix>
15+
<VersionSuffix>1.2.8.$([System.DateTime]::UtcNow.DayOfYear.ToString().PadLeft(3, "0"))$([System.DateTime]::UtcNow.Hour)</VersionSuffix>
1616
<AssemblyVersion Condition=" '$(VersionSuffix)' == '' ">0.0.0.1</AssemblyVersion>
1717
<AssemblyVersion Condition=" '$(VersionSuffix)' != '' ">$(VersionSuffix)</AssemblyVersion>
1818
<Version Condition=" '$(VersionSuffix)' == '' ">0.0.1.0</Version>

ObservatoryCore/PluginManagement/PluginCore.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,13 @@ public void CancelNotification(Guid id)
9090
}
9191

9292
public void UpdateNotification(Guid id, NotificationArgs notificationArgs)
93+
{
94+
// Always use explicitly passed Guid.
95+
notificationArgs.Guid = id;
96+
UpdateNotification(notificationArgs);
97+
}
98+
99+
public void UpdateNotification(NotificationArgs notificationArgs)
93100
{
94101
if (!IsLogMonitorBatchReading)
95102
{
@@ -100,7 +107,7 @@ public void UpdateNotification(Guid id, NotificationArgs notificationArgs)
100107
}
101108

102109
if ((notificationArgs.Rendering & NotificationRendering.NativeVisual) != 0)
103-
NativePopup.UpdateNotification(id, notificationArgs);
110+
NativePopup.UpdateNotification(notificationArgs);
104111

105112
if (Properties.Core.Default.VoiceNotify && (notificationArgs.Rendering & NotificationRendering.NativeVocal) != 0)
106113
{

ObservatoryFramework/Interfaces.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,8 +230,15 @@ public interface IObservatoryCore
230230
/// </summary>
231231
/// <param name="notificationId">Guid of notification to be updated.</param>
232232
/// <param name="notificationEventArgs">NotificationArgs object specifying updated notification content and behaviour.</param>
233+
[Obsolete("This method has been deprecated in favour of UpdateNotification(NotificationArgs notificationEventArgs)")]
233234
public void UpdateNotification(Guid notificationId, NotificationArgs notificationEventArgs);
234235

236+
/// <summary>
237+
/// Update an active notification with a new set of NotificationsArgs. Timeout values are reset and begin counting again from zero if specified.
238+
/// </summary>
239+
/// <param name="notificationEventArgs">NotificationArgs object specifying updated notification content and behaviour.</param>
240+
public void UpdateNotification(NotificationArgs notificationEventArgs);
241+
235242
/// <summary>
236243
/// Add an item to the bottom of the basic UI grid.
237244
/// </summary>

ObservatoryFramework/ObservatoryFramework.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)