From 492b1715e40abe30d9733d96e5bab960fd7ae557 Mon Sep 17 00:00:00 2001 From: "kay.one" Date: Sat, 14 Sep 2013 16:43:03 -0700 Subject: [PATCH] less chatty command events. --- NzbDrone.Core/Messaging/Commands/CommandExecutor.cs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/NzbDrone.Core/Messaging/Commands/CommandExecutor.cs b/NzbDrone.Core/Messaging/Commands/CommandExecutor.cs index f54340a9c..dd3175304 100644 --- a/NzbDrone.Core/Messaging/Commands/CommandExecutor.cs +++ b/NzbDrone.Core/Messaging/Commands/CommandExecutor.cs @@ -101,7 +101,7 @@ namespace NzbDrone.Core.Messaging.Commands try { _trackCommands.Start(command); - _eventAggregator.PublishEvent(new CommandUpdatedEvent(command)); + BroadcastCommandUpdate(command); if (!MappedDiagnosticsContext.Contains("CommandId") && command.SendUpdatesToClient) { @@ -118,7 +118,7 @@ namespace NzbDrone.Core.Messaging.Commands } finally { - _eventAggregator.PublishEvent(new CommandUpdatedEvent(command)); + BroadcastCommandUpdate(command); _eventAggregator.PublishEvent(new CommandExecutedEvent(command)); if (MappedDiagnosticsContext.Get("CommandId") == command.Id.ToString()) @@ -129,5 +129,14 @@ namespace NzbDrone.Core.Messaging.Commands _logger.Trace("{0} <- {1} [{2}]", command.GetType().Name, handler.GetType().Name, command.Runtime.ToString("")); } + + + private void BroadcastCommandUpdate(Command command) + { + if (command.SendUpdatesToClient) + { + _eventAggregator.PublishEvent(new CommandUpdatedEvent(command)); + } + } } }