Skip to content

Commit

Permalink
Null checking
Browse files Browse the repository at this point in the history
  • Loading branch information
blakepell committed Aug 18, 2022
1 parent c2ef38e commit f46d0ce
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
10 changes: 5 additions & 5 deletions src/Avalon.Client/HashCommands/Beep.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,19 +43,19 @@ public override void Execute()
switch (o.BeepType)
{
case BeepType.Beep:
SystemSounds.Beep.Play();
SystemSounds.Beep?.Play();
return;
case BeepType.Asterisk:
SystemSounds.Asterisk.Play();
SystemSounds.Asterisk?.Play();
return;
case BeepType.Exclamation:
SystemSounds.Exclamation.Play();
SystemSounds.Exclamation?.Play();
return;
case BeepType.Hand:
SystemSounds.Hand.Play();
SystemSounds.Hand?.Play();
return;
case BeepType.Question:
SystemSounds.Question.Play();
SystemSounds.Question?.Play();
return;
case BeepType.Alert:
// Special type, this will play even if other system sounds are muted.
Expand Down
2 changes: 1 addition & 1 deletion src/Avalon.Client/HashCommands/ToastAlarm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public ToastAlarm(IInterpreter interp) : base(interp)

public override void Execute()
{
SystemSounds.Exclamation.Play();
SystemSounds.Exclamation?.Play();
App.Toast.ShowNotification("Avalon", this.Parameters, ToolTipIcon.Warning);
}

Expand Down
10 changes: 9 additions & 1 deletion src/Avalon.Client/MainWindow.Network.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
* @license : MIT
*/

using System.Media;
using Avalon.Colors;
using Avalon.Common.Models;
using Avalon.Controls;
Expand Down Expand Up @@ -139,7 +140,14 @@ public void HandleLineReceived(object sender, string e)
// One beep per line max, everything else is ignored.
if (App.Settings.ProfileSettings.AnsiBeep && e.Contains('\a'))
{
App.Beep?.Play();
if (App.Beep != null)
{
App.Beep.Play();
}
else
{
SystemSounds.Beep?.Play();
}
}

try
Expand Down

0 comments on commit f46d0ce

Please sign in to comment.