refactor redux data model

This commit is contained in:
seavor 2026-04-15 21:48:03 -05:00
parent ae1bc3da38
commit 0ff391491d
243 changed files with 5212 additions and 5963 deletions

View file

@ -0,0 +1,232 @@
import { App, Data, Enriched } from '@app/types';
import type { ISessionResponse } from '@app/websocket';
import { GameDispatch, RoomsDispatch, ServerDispatch } from '@app/store';
export class SessionResponseImpl implements ISessionResponse {
initialized(): void {
ServerDispatch.initialized();
}
connectionAttempted(): void {
ServerDispatch.connectionAttempted();
}
clearStore(): void {
ServerDispatch.clearStore();
}
loginSuccessful(options: Enriched.LoginSuccessContext): void {
ServerDispatch.loginSuccessful(options);
}
loginFailed(): void {
ServerDispatch.loginFailed();
}
connectionFailed(): void {
ServerDispatch.connectionFailed();
}
testConnectionSuccessful(): void {
ServerDispatch.testConnectionSuccessful();
}
testConnectionFailed(): void {
ServerDispatch.testConnectionFailed();
}
updateBuddyList(buddyList: Data.ServerInfo_User[]): void {
ServerDispatch.updateBuddyList(buddyList);
}
addToBuddyList(user: Data.ServerInfo_User): void {
ServerDispatch.addToBuddyList(user);
}
removeFromBuddyList(userName: string): void {
ServerDispatch.removeFromBuddyList(userName);
}
updateIgnoreList(ignoreList: Data.ServerInfo_User[]): void {
ServerDispatch.updateIgnoreList(ignoreList);
}
addToIgnoreList(user: Data.ServerInfo_User): void {
ServerDispatch.addToIgnoreList(user);
}
removeFromIgnoreList(userName: string): void {
ServerDispatch.removeFromIgnoreList(userName);
}
updateInfo(name: string, version: string): void {
ServerDispatch.updateInfo(name, version);
}
updateStatus(state: App.StatusEnum, description: string): void {
if (state === App.StatusEnum.DISCONNECTED) {
GameDispatch.clearStore();
RoomsDispatch.clearStore();
ServerDispatch.clearStore();
}
ServerDispatch.updateStatus(state, description);
}
updateUser(user: Data.ServerInfo_User): void {
ServerDispatch.updateUser(user);
}
updateUsers(users: Data.ServerInfo_User[]): void {
ServerDispatch.updateUsers(users);
}
userJoined(user: Data.ServerInfo_User): void {
ServerDispatch.userJoined(user);
}
userLeft(userName: string): void {
ServerDispatch.userLeft(userName);
}
serverMessage(message: string): void {
ServerDispatch.serverMessage(message);
}
accountAwaitingActivation(options: Enriched.PendingActivationContext): void {
ServerDispatch.accountAwaitingActivation(options);
}
accountActivationSuccess(): void {
ServerDispatch.accountActivationSuccess();
}
accountActivationFailed(): void {
ServerDispatch.accountActivationFailed();
}
registrationRequiresEmail(): void {
ServerDispatch.registrationRequiresEmail();
}
registrationSuccess(): void {
ServerDispatch.registrationSuccess();
}
registrationFailed(reason: string, endTime?: number): void {
ServerDispatch.registrationFailed(reason, endTime);
}
registrationEmailError(error: string): void {
ServerDispatch.registrationEmailError(error);
}
registrationPasswordError(error: string): void {
ServerDispatch.registrationPasswordError(error);
}
registrationUserNameError(error: string): void {
ServerDispatch.registrationUserNameError(error);
}
resetPasswordChallenge(): void {
ServerDispatch.resetPasswordChallenge();
}
resetPassword(): void {
ServerDispatch.resetPassword();
}
resetPasswordSuccess(): void {
ServerDispatch.resetPasswordSuccess();
}
resetPasswordFailed(): void {
ServerDispatch.resetPasswordFailed();
}
accountPasswordChange(): void {
ServerDispatch.accountPasswordChange();
}
accountEditChanged(realName?: string, email?: string, country?: string): void {
ServerDispatch.accountEditChanged({ realName, email, country });
}
accountImageChanged(avatarBmp: Uint8Array): void {
ServerDispatch.accountImageChanged({ avatarBmp });
}
getUserInfo(userInfo: Data.ServerInfo_User): void {
ServerDispatch.getUserInfo(userInfo);
}
getGamesOfUser(userName: string, response: Data.Response_GetGamesOfUser): void {
ServerDispatch.gamesOfUser(userName, response);
}
gameJoined(gameJoinedData: Data.Event_GameJoined): void {
GameDispatch.gameJoined(gameJoinedData);
}
notifyUser(notification: Data.Event_NotifyUser): void {
ServerDispatch.notifyUser(notification);
}
playerPropertiesChanged(gameId: number, playerId: number, payload: Data.Event_PlayerPropertiesChanged): void {
if (payload.playerProperties) {
GameDispatch.playerPropertiesChanged(gameId, playerId, payload.playerProperties);
}
}
serverShutdown(data: Data.Event_ServerShutdown): void {
ServerDispatch.serverShutdown(data);
}
userMessage(messageData: Data.Event_UserMessage): void {
ServerDispatch.userMessage(messageData);
}
addToList(list: string, userName: string): void {
ServerDispatch.addToList(list, userName);
}
removeFromList(list: string, userName: string): void {
ServerDispatch.removeFromList(list, userName);
}
deleteServerDeck(deckId: number): void {
ServerDispatch.deckDelete(deckId);
}
updateServerDecks(deckList: Data.Response_DeckList): void {
ServerDispatch.backendDecks(deckList);
}
uploadServerDeck(path: string, treeItem: Data.ServerInfo_DeckStorage_TreeItem): void {
ServerDispatch.deckUpload(path, treeItem);
}
createServerDeckDir(path: string, dirName: string): void {
ServerDispatch.deckNewDir(path, dirName);
}
deleteServerDeckDir(path: string): void {
ServerDispatch.deckDelDir(path);
}
replayList(matchList: Data.ServerInfo_ReplayMatch[]): void {
ServerDispatch.replayList(matchList);
}
replayAdded(matchInfo: Data.ServerInfo_ReplayMatch): void {
ServerDispatch.replayAdded(matchInfo);
}
replayModifyMatch(gameId: number, doNotHide: boolean): void {
ServerDispatch.replayModifyMatch(gameId, doNotHide);
}
replayDeleteMatch(gameId: number): void {
ServerDispatch.replayDeleteMatch(gameId);
}
}