Fix ahelp window not appearing on first init (#45393)

This commit is contained in:
eoineoineoin 2026-08-16 15:31:35 +00:00 • committed by GitHub
parent 4e03cf2411
commit 82fb72da50
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -518,14 +518,14 @@ public sealed class UserAHelpUIHandler : IAHelpUIHandler
public void ToggleWindow()
{
EnsureInit(_discordRelayActive);
if (_window!.IsOpen)
var createdWindow = EnsureInit(_discordRelayActive);
if (!createdWindow && _window!.IsOpen)
{
_window.Close();
}
else
{
_window.OpenCentered();
_window!.OpenCentered();
}
}
@ -559,10 +559,14 @@ public sealed class UserAHelpUIHandler : IAHelpUIHandler
_window!.OpenCentered();
}
private void EnsureInit(bool relayActive)
/// <summary>
/// Create new ahelp window or return existing window
/// </summary>
/// <returns>True if new window was created</returns>
private bool EnsureInit(bool relayActive)
{
if (_window is { Disposed: false })
return;
return false;
_chatPanel = new BwoinkPanel(text => SendMessageAction?.Invoke(_ownerId, text, true, false));
_chatPanel.InputTextChanged += text => InputTextChanged?.Invoke(_ownerId, text);
_chatPanel.RelayedToDiscordLabel.Visible = relayActive;
@ -580,6 +584,7 @@ public sealed class UserAHelpUIHandler : IAHelpUIHandler
var introText = Loc.GetString("bwoink-system-introductory-message");
var introMessage = new SharedBwoinkSystem.BwoinkTextMessage( _ownerId, SharedBwoinkSystem.SystemUserId, introText);
Receive(introMessage);
return true;
}
public void Dispose()