Fix Async hiccup in chat.
This commit is contained in:
@@ -1000,23 +1000,26 @@ public sealed class ZoneChatUi : WindowMediatorSubscriberBase
|
|||||||
if (sanitized is not null)
|
if (sanitized is not null)
|
||||||
{
|
{
|
||||||
TrackPendingDraftClear(channel.Key, sanitized);
|
TrackPendingDraftClear(channel.Key, sanitized);
|
||||||
|
draft = string.Empty;
|
||||||
|
_draftMessages[channel.Key] = draft;
|
||||||
|
_scrollToBottom = true;
|
||||||
|
|
||||||
if (TrySendDraft(channel, sanitized))
|
_ = Task.Run(async () =>
|
||||||
{
|
{
|
||||||
_scrollToBottom = true;
|
try
|
||||||
|
|
||||||
if (_draftMessages.TryGetValue(channel.Key, out var current) &&
|
|
||||||
string.Equals(current, draftAtSend, StringComparison.Ordinal))
|
|
||||||
{
|
{
|
||||||
draft = string.Empty;
|
var succeeded = await _zoneChatService.SendMessageAsync(channel.Descriptor, sanitized).ConfigureAwait(false);
|
||||||
_draftMessages[channel.Key] = draft;
|
if (!succeeded)
|
||||||
|
{
|
||||||
|
RemovePendingDraftClear(channel.Key, sanitized);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
catch (Exception ex)
|
||||||
}
|
{
|
||||||
else
|
_logger.LogWarning(ex, "Failed to send chat message");
|
||||||
{
|
RemovePendingDraftClear(channel.Key, sanitized);
|
||||||
RemovePendingDraftClear(channel.Key, sanitized);
|
}
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user