Add ahelp typing indicator for admins (#19060)
* Add ahelp typing indicator for admins * Lower typing updates throttle from 3 seconds to 1 * Add stopping typing when sending a message * Lower typing indicator timeout from 15 to 10 seconds
This commit is contained in:
@@ -2,13 +2,17 @@
|
||||
using Content.Shared.Administration;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Shared.Network;
|
||||
using Robust.Shared.Timing;
|
||||
|
||||
namespace Content.Client.Administration.Systems
|
||||
{
|
||||
[UsedImplicitly]
|
||||
public sealed class BwoinkSystem : SharedBwoinkSystem
|
||||
{
|
||||
[Dependency] private readonly IGameTiming _timing = default!;
|
||||
|
||||
public event EventHandler<BwoinkTextMessage>? OnBwoinkTextMessageRecieved;
|
||||
private (TimeSpan Timestamp, bool Typing) _lastTypingUpdateSent;
|
||||
|
||||
protected override void OnBwoinkTextMessage(BwoinkTextMessage message, EntitySessionEventArgs eventArgs)
|
||||
{
|
||||
@@ -20,6 +24,19 @@ namespace Content.Client.Administration.Systems
|
||||
// Reuse the channel ID as the 'true sender'.
|
||||
// Server will ignore this and if someone makes it not ignore this (which is bad, allows impersonation!!!), that will help.
|
||||
RaiseNetworkEvent(new BwoinkTextMessage(channelId, channelId, text));
|
||||
SendInputTextUpdated(channelId, false);
|
||||
}
|
||||
|
||||
public void SendInputTextUpdated(NetUserId channel, bool typing)
|
||||
{
|
||||
if (_lastTypingUpdateSent.Typing == typing &&
|
||||
_lastTypingUpdateSent.Timestamp + TimeSpan.FromSeconds(1) > _timing.RealTime)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_lastTypingUpdateSent = (_timing.RealTime, typing);
|
||||
RaiseNetworkEvent(new BwoinkClientTypingUpdated(channel, typing));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user