Merge pull request 'Fix Async hiccup in chat.' (#117) from quick-chat-fix into 2.0.2

Reviewed-on: #117
Reviewed-by: cake <cake@noreply.git.lightless-sync.org>
This commit was merged in pull request #117.
This commit is contained in:
2025-12-28 03:58:35 +00:00

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