From ad205728792dc19fa746d6f2b0863f4c69ac2b67 Mon Sep 17 00:00:00 2001 From: RaidMax Date: Mon, 3 Apr 2023 15:56:13 -0500 Subject: [PATCH] update readmessage command to use TellAsync --- Application/Commands/ReadMessageCommand.cs | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/Application/Commands/ReadMessageCommand.cs b/Application/Commands/ReadMessageCommand.cs index dde5ef2d3..bac94cdea 100644 --- a/Application/Commands/ReadMessageCommand.cs +++ b/Application/Commands/ReadMessageCommand.cs @@ -49,20 +49,13 @@ namespace IW4MAdmin.Application.Commands return; } - var index = 1; - foreach (var inboxItem in inboxItems) + await gameEvent.Origin.TellAsync(inboxItems.Select((inboxItem, index) => { - await gameEvent.Origin.Tell(_translationLookup["COMMANDS_READ_MESSAGE_SUCCESS"] - .FormatExt($"{index}/{inboxItems.Count}", inboxItem.SourceClient.CurrentAlias.Name)) - .WaitAsync(); + var header = _translationLookup["COMMANDS_READ_MESSAGE_SUCCESS"] + .FormatExt($"{index + 1}/{inboxItems.Count}", inboxItem.SourceClient.CurrentAlias.Name); - foreach (var messageFragment in inboxItem.Message.FragmentMessageForDisplay()) - { - await gameEvent.Origin.Tell(messageFragment).WaitAsync(); - } - - index++; - } + return new[] { header }.Union(inboxItem.Message.FragmentMessageForDisplay()); + }).SelectMany(item => item)); inboxItems.ForEach(item => { item.IsDelivered = true; });