Skip to content

Commit

Permalink
feat(skymp5-client): improve auth ux in error scenario (skyrim-multip…
Browse files Browse the repository at this point in the history
  • Loading branch information
Pospelove authored Aug 28, 2024
1 parent e2af520 commit c97ac04
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion skymp5-client/src/services/services/authService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ const events = {
clearAuthData: 'clearAuthData',
updateRequired: 'updateRequired',
backToLogin: 'backToLogin',
joinDiscord: 'joinDiscord'
};

// Vaiables used on both client and browser side (see browsersideWidgetSetter)
Expand Down Expand Up @@ -108,27 +109,31 @@ export class AuthService extends ClientListener {
this.controller.lookupListener(NetworkingService).close();
logTrace(this, 'loginFailedNotLoggedViaDiscord received');
browserState.loginFailedReason = 'войдите через discord';
browserState.comment = '';
this.sp.browser.executeJavaScript(new FunctionInfo(this.loginFailedWidgetSetter).getText({ events, browserState, authData: authData }));
break;
case 'loginFailedNotInTheDiscordServer':
this.authAttemptProgressIndicator = false;
this.controller.lookupListener(NetworkingService).close();
logTrace(this, 'loginFailedNotInTheDiscordServer received');
browserState.loginFailedReason = 'вступите в discord сервер';
browserState.comment = '';
this.sp.browser.executeJavaScript(new FunctionInfo(this.loginFailedWidgetSetter).getText({ events, browserState, authData: authData }));
break;
case 'loginFailedBanned':
this.authAttemptProgressIndicator = false;
this.controller.lookupListener(NetworkingService).close();
logTrace(this, 'loginFailedBanned received');
browserState.loginFailedReason = 'вы забанены';
browserState.comment = '';
this.sp.browser.executeJavaScript(new FunctionInfo(this.loginFailedWidgetSetter).getText({ events, browserState, authData: authData }));
break;
case 'loginFailedIpMismatch':
this.authAttemptProgressIndicator = false;
this.controller.lookupListener(NetworkingService).close();
logTrace(this, 'loginFailedIpMismatch received');
browserState.comment = 'что это было?';
browserState.loginFailedReason = 'что это было?';
browserState.comment = '';
this.sp.browser.executeJavaScript(new FunctionInfo(this.loginFailedWidgetSetter).getText({ events, browserState, authData: authData }));
break;
}
Expand Down Expand Up @@ -206,6 +211,9 @@ export class AuthService extends ClientListener {
case events.backToLogin:
this.sp.browser.executeJavaScript(new FunctionInfo(this.browsersideWidgetSetter).getText({ events, browserState, authData: authData }));
break;
case events.joinDiscord:
this.sp.win32.loadUrl("https://discord.gg/9KhSZ6zjGT");
break;
default:
logError(this, `Unknown event key`, eventKey);
break;
Expand Down Expand Up @@ -413,6 +421,16 @@ export class AuthService extends ClientListener {

textElements.forEach((element) => widget.elements.push(element));

if (browserState.loginFailedReason === 'вступите в discord сервер') {
widget.elements.push({
type: "button",
text: "вступить",
tags: ["ELEMENT_STYLE_MARGIN_EXTENDED"],
click: () => window.skyrimPlatform.sendMessage(events.joinDiscord),
hint: null
});
}

widget.elements.push({
type: "button",
text: "назад",
Expand Down

0 comments on commit c97ac04

Please sign in to comment.