Fix Async hiccup in chat.

This commit is contained in:
defnotken
2025-12-27 21:57:01 -06:00
parent ff88e5f856
commit 759066731e

View File

@@ -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);
}
});
}
}
}