Skip to content

Conversation

Copy link

Copilot AI commented Aug 23, 2025

Problem

Toast notifications were not appearing immediately when validation failed on login and register screens. Users would click the login button with empty password, but the toast would only appear after navigating to another screen (like clicking the register button).

Root Cause

The issue was caused by timing problems in the Minecraft rendering pipeline. Toast calls made directly in button event handlers (UtilToast.toast()) were added to Minecraft's toast manager but not processed until the next screen refresh cycle.

Solution

Wrapped all immediate toast calls in ctx.get().enqueueWork{} blocks to ensure they execute in the proper render cycle timing. This follows the same pattern already used successfully in PacketResponse.handle() for network-triggered toasts.

Changes Made

Before:

if (this.passwordEditBox.value.isEmpty()) {
    UtilToast.toast(UtilComponent.getTranslatableComponent(Lang.Auth.EMPTY))
    return@Button
}

After:

if (this.passwordEditBox.value.isEmpty()) {
    this.ctx.get().enqueueWork {
        UtilToast.toast(UtilComponent.getTranslatableComponent(Lang.Auth.EMPTY))
    }
    return@Button
}

Applied to:

  • Login screen empty password validation (both forge-1.19.2 and forge-1.20.1)
  • Register screen empty password validation (both versions)
  • Register screen password mismatch validation (both versions)

Expected Behavior

After this fix:

  • Empty password toasts display immediately when clicking login with no password
  • Password mismatch toasts display immediately when passwords don't match on register
  • No more delayed toast display requiring screen navigation to see validation messages

Testing

The fix follows the established pattern used by PacketResponse.handle() which successfully displays toasts for network responses, ensuring consistency with existing working code.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • mirrors.cloud.tencent.com
    • Triggering command: /usr/lib/jvm/temurin-17-jdk-amd64/bin/java -Xmx64m -Xms64m -Dorg.gradle.appname=gradlew -classpath /home/REDACTED/work/AsyncAuth/AsyncAuth/gradle/wrapper/gradle-wrapper.jar org.gradle.wrapper.GradleWrapperMain projects (dns block)

If you need me to access, download, or install something from one of these locations, you can either:


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

@LystranG LystranG marked this pull request as ready for review August 23, 2025 02:12
@LystranG LystranG closed this Aug 23, 2025
Copilot AI changed the title [WIP] 在登录页面点击登录后不显示toast,点击了注册按钮进入注册页面才看到了刚才登录所弹出的toast,什么问题? Fix toast notifications not displaying immediately on login/register screens Aug 23, 2025
Copilot AI requested a review from LystranG August 23, 2025 02:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants