From 04290e70386fbbd4702defd800a62c39ab3c730d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maur=C3=ADcio=20Vielmo=20Schmaedeck?= Date: Tue, 14 Apr 2020 15:23:47 -0300 Subject: [PATCH] refactor(server): Nest if to prevent checking two times for the same condition --- RemoteFlix.Base/RemoteFlixServer.cs | 10 +++++----- RemoteFlix.UI.Desktop/ViewModel/MainViewModel.cs | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/RemoteFlix.Base/RemoteFlixServer.cs b/RemoteFlix.Base/RemoteFlixServer.cs index ce39452..66dfb01 100644 --- a/RemoteFlix.Base/RemoteFlixServer.cs +++ b/RemoteFlix.Base/RemoteFlixServer.cs @@ -213,12 +213,12 @@ private bool ExecuteCommand(BasePlayer player, PlayerCommand command) if (playerHandle == null) { playerHandle = KeyboardSimulationHelper.GetForegroundWindow(); - } - // If this also fails, there isn't much we can do - if(playerHandle == null || playerHandle.Value == IntPtr.Zero) - { - return false; + // If this also fails, there isn't much we can do + if (playerHandle.Value == IntPtr.Zero) + { + return false; + } } KeyboardSimulationHelper.SendKeys(playerHandle.Value, command.ActionShortcut); diff --git a/RemoteFlix.UI.Desktop/ViewModel/MainViewModel.cs b/RemoteFlix.UI.Desktop/ViewModel/MainViewModel.cs index 07686ba..e6e7494 100644 --- a/RemoteFlix.UI.Desktop/ViewModel/MainViewModel.cs +++ b/RemoteFlix.UI.Desktop/ViewModel/MainViewModel.cs @@ -112,7 +112,7 @@ private void SetupEnvironment() private void LogReceived(object sender, NotifyCollectionChangedEventArgs e) { // It is safe to do this since there's only one method to modify the collection and it - // adds (one) log. So every time the collection changes it is an addition of one item. + // adds *one* log. So every time the collection changes it is an addition of one item. var log = e.NewItems[0] as Log; Application.Current.Dispatcher.Invoke(() => Logs.Add(log));