diff --git a/LightlessSync/UI/ZoneChatUi.cs b/LightlessSync/UI/ZoneChatUi.cs index 036e7d3..cb6dae8 100644 --- a/LightlessSync/UI/ZoneChatUi.cs +++ b/LightlessSync/UI/ZoneChatUi.cs @@ -1000,23 +1000,26 @@ public sealed class ZoneChatUi : WindowMediatorSubscriberBase if (sanitized is not null) { TrackPendingDraftClear(channel.Key, sanitized); + draft = string.Empty; + _draftMessages[channel.Key] = draft; + _scrollToBottom = true; - if (TrySendDraft(channel, sanitized)) + _ = Task.Run(async () => { - _scrollToBottom = true; - - if (_draftMessages.TryGetValue(channel.Key, out var current) && - string.Equals(current, draftAtSend, StringComparison.Ordinal)) + try { - draft = string.Empty; - _draftMessages[channel.Key] = draft; + var succeeded = await _zoneChatService.SendMessageAsync(channel.Descriptor, sanitized).ConfigureAwait(false); + if (!succeeded) + { + RemovePendingDraftClear(channel.Key, sanitized); + } } - - } - else - { - RemovePendingDraftClear(channel.Key, sanitized); - } + catch (Exception ex) + { + _logger.LogWarning(ex, "Failed to send chat message"); + RemovePendingDraftClear(channel.Key, sanitized); + } + }); } } }