diff --git a/skymp5-client/src/services/services/authService.ts b/skymp5-client/src/services/services/authService.ts index 907a3f1de4..7eabd8f81d 100644 --- a/skymp5-client/src/services/services/authService.ts +++ b/skymp5-client/src/services/services/authService.ts @@ -84,6 +84,15 @@ export class AuthService extends ClientListener { logTrace(this, `Received createActorMessage for self, resetting widgets`); this.sp.browser.executeJavaScript('window.skyrimPlatform.widgets.set([]);'); this.authDialogOpen = false; + + // The idea is to write authData to disk after auth dialog is closed + // This is because write to plugins dir triggers hotreload, which in turn breaks the auth dialog + // So we need to write to disk after dialog is closed + if (this.authDataWriteTask) { + const task = this.authDataWriteTask.authDataToWrite; + this.controller.once("update", () => this.writeAuthDataToDisk(task)); + this.authDataWriteTask = null; + } } else { logTrace(this, `Received createActorMessage for self, but auth dialog was not open so not resetting widgets`); @@ -183,7 +192,7 @@ export class AuthService extends ClientListener { this.refreshWidgets(); break; } - this.writeAuthDataToDisk(authData); + this.authDataWriteTask = { authDataToWrite: authData }; this.controller.emitter.emit("authAttempt", { authGameData: { remote: authData } }); this.authAttemptProgressIndicator = true; @@ -191,7 +200,8 @@ export class AuthService extends ClientListener { break; case events.clearAuthData: - this.writeAuthDataToDisk(null); + // Doesn't seem to be used + this.authDataWriteTask = { authDataToWrite: null }; break; case events.openGithub: this.sp.win32.loadUrl(this.githubUrl); @@ -571,8 +581,11 @@ export class AuthService extends ClientListener { this.authAttemptProgressIndicator = false; this.controller.lookupListener(NetworkingService).close(); logTrace(this, 'max logging delay reached received'); + browserState.comment = ""; browserState.loginFailedReason = 'технические шоколадки\nпопробуйте еще раз\nпожалуйста\nили напишите нам в discord'; this.sp.browser.executeJavaScript(new FunctionInfo(this.loginFailedWidgetSetter).getText({ events, browserState, authData: authData })); + + authData = null; } if (this.authAttemptProgressIndicator) { @@ -617,6 +630,8 @@ export class AuthService extends ClientListener { private authAttemptProgressIndicator = false; private authAttemptProgressIndicatorCounter = 0; + private authDataWriteTask: { authDataToWrite: RemoteAuthGameData | null } | null = null; + private readonly githubUrl = "https://github.com/skyrim-multiplayer/skymp"; private readonly patreonUrl = "https://www.patreon.com/skymp"; private readonly pluginAuthDataName = `auth-data-no-load`;