mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-06-10 00:04:48 -07:00
refactor typescript wiring
This commit is contained in:
parent
cea9ae62d8
commit
c62c336a11
286 changed files with 2999 additions and 3053 deletions
|
|
@ -1,31 +1,34 @@
|
|||
import { AccountActivationParams } from 'store';
|
||||
import { StatusEnum, WebSocketConnectOptions } from 'types';
|
||||
import { App, Enriched, Data } from '@app/types';
|
||||
|
||||
import { create } from '@bufbuild/protobuf';
|
||||
import { CLIENT_CONFIG } from '../../config';
|
||||
import webClient from '../../WebClient';
|
||||
import { Command_Activate_ext, Command_ActivateSchema } from 'generated/proto/session_commands_pb';
|
||||
|
||||
import { SessionPersistence } from '../../persistence';
|
||||
import { Response_ResponseCode } from 'generated/proto/response_pb';
|
||||
|
||||
import { disconnect, login, updateStatus } from './';
|
||||
|
||||
export function activate(options: WebSocketConnectOptions, password?: string, passwordSalt?: string): void {
|
||||
const { userName, token } = options as unknown as AccountActivationParams;
|
||||
export function activate(options: Omit<Enriched.ActivateConnectOptions, 'password'>, password?: string, passwordSalt?: string): void {
|
||||
const { userName, token } = options;
|
||||
|
||||
webClient.protobuf.sendSessionCommand(Command_Activate_ext, create(Command_ActivateSchema, {
|
||||
webClient.protobuf.sendSessionCommand(Data.Command_Activate_ext, create(Data.Command_ActivateSchema, {
|
||||
...CLIENT_CONFIG,
|
||||
userName,
|
||||
token,
|
||||
}), {
|
||||
onResponseCode: {
|
||||
[Response_ResponseCode.RespActivationAccepted]: () => {
|
||||
[Data.Response_ResponseCode.RespActivationAccepted]: () => {
|
||||
SessionPersistence.accountActivationSuccess();
|
||||
login(options, password, passwordSalt);
|
||||
login({
|
||||
host: options.host,
|
||||
port: options.port,
|
||||
userName: options.userName,
|
||||
reason: App.WebSocketConnectReason.LOGIN,
|
||||
}, password, passwordSalt);
|
||||
},
|
||||
},
|
||||
onError: () => {
|
||||
updateStatus(StatusEnum.DISCONNECTED, 'Account Activation Failed');
|
||||
updateStatus(App.StatusEnum.DISCONNECTED, 'Account Activation Failed');
|
||||
disconnect();
|
||||
SessionPersistence.accountActivationFailed();
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue