mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-06-10 08:14:47 -07:00
refactor typescript wiring
This commit is contained in:
parent
cea9ae62d8
commit
c62c336a11
286 changed files with 2999 additions and 3053 deletions
|
|
@ -1,16 +1,4 @@
|
|||
import {
|
||||
GametypeMap, WebSocketConnectOptions
|
||||
} from 'types';
|
||||
import type { ServerInfo_User } from 'generated/proto/serverinfo_user_pb';
|
||||
import type { ServerInfo_Ban } from 'generated/proto/serverinfo_ban_pb';
|
||||
import type { ServerInfo_Warning } from 'generated/proto/serverinfo_warning_pb';
|
||||
import type { Response_WarnList } from 'generated/proto/response_warn_list_pb';
|
||||
import type { ServerInfo_ReplayMatch } from 'generated/proto/serverinfo_replay_match_pb';
|
||||
import type { Response_DeckList } from 'generated/proto/response_deck_list_pb';
|
||||
import type { ServerInfo_DeckStorage_TreeItem } from 'generated/proto/serverinfo_deckstorage_pb';
|
||||
import type { ServerInfo_ChatMessage } from 'generated/proto/serverinfo_chat_message_pb';
|
||||
import type { ServerInfo_Game } from 'generated/proto/serverinfo_game_pb';
|
||||
import { NotifyUserData, ServerShutdownData, UserMessageData } from 'websocket/events/session/interfaces';
|
||||
import { Data, Enriched } from '@app/types';
|
||||
import { ServerStateStatus } from './server.interfaces';
|
||||
import { Types } from './server.types';
|
||||
|
||||
|
|
@ -24,17 +12,13 @@ export const Actions = {
|
|||
connectionAttempted: () => ({
|
||||
type: Types.CONNECTION_ATTEMPTED
|
||||
}),
|
||||
loginSuccessful: (options: WebSocketConnectOptions) => ({
|
||||
loginSuccessful: (options: Enriched.LoginSuccessContext) => ({
|
||||
type: Types.LOGIN_SUCCESSFUL,
|
||||
options
|
||||
}),
|
||||
loginFailed: () => ({
|
||||
type: Types.LOGIN_FAILED,
|
||||
}),
|
||||
connectionClosed: (reason: number) => ({
|
||||
type: Types.CONNECTION_CLOSED,
|
||||
reason
|
||||
}),
|
||||
connectionFailed: () => ({
|
||||
type: Types.CONNECTION_FAILED,
|
||||
}),
|
||||
|
|
@ -48,11 +32,11 @@ export const Actions = {
|
|||
type: Types.SERVER_MESSAGE,
|
||||
message
|
||||
}),
|
||||
updateBuddyList: (buddyList: ServerInfo_User[]) => ({
|
||||
updateBuddyList: (buddyList: Data.ServerInfo_User[]) => ({
|
||||
type: Types.UPDATE_BUDDY_LIST,
|
||||
buddyList
|
||||
}),
|
||||
addToBuddyList: (user: ServerInfo_User) => ({
|
||||
addToBuddyList: (user: Data.ServerInfo_User) => ({
|
||||
type: Types.ADD_TO_BUDDY_LIST,
|
||||
user
|
||||
}),
|
||||
|
|
@ -60,11 +44,11 @@ export const Actions = {
|
|||
type: Types.REMOVE_FROM_BUDDY_LIST,
|
||||
userName
|
||||
}),
|
||||
updateIgnoreList: (ignoreList: ServerInfo_User[]) => ({
|
||||
updateIgnoreList: (ignoreList: Data.ServerInfo_User[]) => ({
|
||||
type: Types.UPDATE_IGNORE_LIST,
|
||||
ignoreList
|
||||
}),
|
||||
addToIgnoreList: (user: ServerInfo_User) => ({
|
||||
addToIgnoreList: (user: Data.ServerInfo_User) => ({
|
||||
type: Types.ADD_TO_IGNORE_LIST,
|
||||
user
|
||||
}),
|
||||
|
|
@ -76,19 +60,19 @@ export const Actions = {
|
|||
type: Types.UPDATE_INFO,
|
||||
info
|
||||
}),
|
||||
updateStatus: (status: ServerStateStatus) => ({
|
||||
updateStatus: (status: Pick<ServerStateStatus, 'state' | 'description'>) => ({
|
||||
type: Types.UPDATE_STATUS,
|
||||
status
|
||||
}),
|
||||
updateUser: (user: ServerInfo_User) => ({
|
||||
updateUser: (user: Data.ServerInfo_User) => ({
|
||||
type: Types.UPDATE_USER,
|
||||
user
|
||||
}),
|
||||
updateUsers: (users: ServerInfo_User[]) => ({
|
||||
updateUsers: (users: Data.ServerInfo_User[]) => ({
|
||||
type: Types.UPDATE_USERS,
|
||||
users
|
||||
}),
|
||||
userJoined: (user: ServerInfo_User) => ({
|
||||
userJoined: (user: Data.ServerInfo_User) => ({
|
||||
type: Types.USER_JOINED,
|
||||
user
|
||||
}),
|
||||
|
|
@ -96,7 +80,7 @@ export const Actions = {
|
|||
type: Types.USER_LEFT,
|
||||
name
|
||||
}),
|
||||
viewLogs: (logs: ServerInfo_ChatMessage[]) => ({
|
||||
viewLogs: (logs: Data.ServerInfo_ChatMessage[]) => ({
|
||||
type: Types.VIEW_LOGS,
|
||||
logs
|
||||
}),
|
||||
|
|
@ -129,7 +113,7 @@ export const Actions = {
|
|||
clearRegistrationErrors: () => ({
|
||||
type: Types.CLEAR_REGISTRATION_ERRORS,
|
||||
}),
|
||||
accountAwaitingActivation: (options: WebSocketConnectOptions) => ({
|
||||
accountAwaitingActivation: (options: Enriched.PendingActivationContext) => ({
|
||||
type: Types.ACCOUNT_AWAITING_ACTIVATION,
|
||||
options
|
||||
}),
|
||||
|
|
@ -169,27 +153,27 @@ export const Actions = {
|
|||
accountPasswordChange: () => ({
|
||||
type: Types.ACCOUNT_PASSWORD_CHANGE,
|
||||
}),
|
||||
accountEditChanged: (user: Partial<ServerInfo_User>) => ({
|
||||
accountEditChanged: (user: Partial<Data.ServerInfo_User>) => ({
|
||||
type: Types.ACCOUNT_EDIT_CHANGED,
|
||||
user,
|
||||
}),
|
||||
accountImageChanged: (user: Partial<ServerInfo_User>) => ({
|
||||
accountImageChanged: (user: Partial<Data.ServerInfo_User>) => ({
|
||||
type: Types.ACCOUNT_IMAGE_CHANGED,
|
||||
user,
|
||||
}),
|
||||
getUserInfo: (userInfo: ServerInfo_User) => ({
|
||||
getUserInfo: (userInfo: Data.ServerInfo_User) => ({
|
||||
type: Types.GET_USER_INFO,
|
||||
userInfo,
|
||||
}),
|
||||
notifyUser: (notification: NotifyUserData) => ({
|
||||
notifyUser: (notification: Data.Event_NotifyUser) => ({
|
||||
type: Types.NOTIFY_USER,
|
||||
notification,
|
||||
}),
|
||||
serverShutdown: (data: ServerShutdownData) => ({
|
||||
serverShutdown: (data: Data.Event_ServerShutdown) => ({
|
||||
type: Types.SERVER_SHUTDOWN,
|
||||
data,
|
||||
}),
|
||||
userMessage: (messageData: UserMessageData) => ({
|
||||
userMessage: (messageData: Data.Event_UserMessage) => ({
|
||||
type: Types.USER_MESSAGE,
|
||||
messageData,
|
||||
}),
|
||||
|
|
@ -207,17 +191,17 @@ export const Actions = {
|
|||
type: Types.BAN_FROM_SERVER,
|
||||
userName,
|
||||
}),
|
||||
banHistory: (userName: string, banHistory: ServerInfo_Ban[]) => ({
|
||||
banHistory: (userName: string, banHistory: Data.ServerInfo_Ban[]) => ({
|
||||
type: Types.BAN_HISTORY,
|
||||
userName,
|
||||
banHistory,
|
||||
}),
|
||||
warnHistory: (userName: string, warnHistory: ServerInfo_Warning[]) => ({
|
||||
warnHistory: (userName: string, warnHistory: Data.ServerInfo_Warning[]) => ({
|
||||
type: Types.WARN_HISTORY,
|
||||
userName,
|
||||
warnHistory,
|
||||
}),
|
||||
warnListOptions: (warnList: Response_WarnList[]) => ({
|
||||
warnListOptions: (warnList: Data.Response_WarnList[]) => ({
|
||||
type: Types.WARN_LIST_OPTIONS,
|
||||
warnList,
|
||||
}),
|
||||
|
|
@ -245,17 +229,17 @@ export const Actions = {
|
|||
userName,
|
||||
notes,
|
||||
}),
|
||||
replayList: (matchList: ServerInfo_ReplayMatch[]) => ({ type: Types.REPLAY_LIST, matchList }),
|
||||
replayAdded: (matchInfo: ServerInfo_ReplayMatch) => ({ type: Types.REPLAY_ADDED, matchInfo }),
|
||||
replayList: (matchList: Data.ServerInfo_ReplayMatch[]) => ({ type: Types.REPLAY_LIST, matchList }),
|
||||
replayAdded: (matchInfo: Data.ServerInfo_ReplayMatch) => ({ type: Types.REPLAY_ADDED, matchInfo }),
|
||||
replayModifyMatch: (gameId: number, doNotHide: boolean) => ({ type: Types.REPLAY_MODIFY_MATCH, gameId, doNotHide }),
|
||||
replayDeleteMatch: (gameId: number) => ({ type: Types.REPLAY_DELETE_MATCH, gameId }),
|
||||
backendDecks: (deckList: Response_DeckList) => ({ type: Types.BACKEND_DECKS, deckList }),
|
||||
backendDecks: (deckList: Data.Response_DeckList) => ({ type: Types.BACKEND_DECKS, deckList }),
|
||||
deckNewDir: (path: string, dirName: string) => ({ type: Types.DECK_NEW_DIR, path, dirName }),
|
||||
deckDelDir: (path: string) => ({ type: Types.DECK_DEL_DIR, path }),
|
||||
deckUpload: (path: string, treeItem: ServerInfo_DeckStorage_TreeItem) => ({ type: Types.DECK_UPLOAD, path, treeItem }),
|
||||
deckUpload: (path: string, treeItem: Data.ServerInfo_DeckStorage_TreeItem) => ({ type: Types.DECK_UPLOAD, path, treeItem }),
|
||||
deckDelete: (deckId: number) => ({ type: Types.DECK_DELETE, deckId }),
|
||||
gamesOfUser: (userName: string, games: ServerInfo_Game[], gametypeMap: GametypeMap) =>
|
||||
({ type: Types.GAMES_OF_USER, userName, games, gametypeMap }),
|
||||
gamesOfUser: (userName: string, response: Data.Response_GetGamesOfUser) =>
|
||||
({ type: Types.GAMES_OF_USER, userName, response }),
|
||||
}
|
||||
|
||||
export type ServerAction = ReturnType<typeof Actions[keyof typeof Actions]>;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue