2022-01-18 15:59:43 +00:00
|
|
|
import { Action } from 'redux';
|
|
|
|
|
|
|
|
import { SERVER } from './actionsTypes';
|
|
|
|
|
2023-10-19 13:38:57 +00:00
|
|
|
export interface ISelectServerAction extends Action {
|
2022-01-18 15:59:43 +00:00
|
|
|
server: string;
|
|
|
|
version?: string;
|
2022-01-20 21:00:04 +00:00
|
|
|
fetchVersion: boolean;
|
|
|
|
changeServer: boolean;
|
2022-01-18 15:59:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
interface ISelectServerSuccess extends Action {
|
|
|
|
server: string;
|
|
|
|
version: string;
|
2023-10-19 13:38:57 +00:00
|
|
|
name: string;
|
2022-01-18 15:59:43 +00:00
|
|
|
}
|
|
|
|
|
2023-10-19 13:38:57 +00:00
|
|
|
export interface IServerRequestAction extends Action {
|
2022-01-18 15:59:43 +00:00
|
|
|
server: string;
|
|
|
|
username: string | null;
|
|
|
|
fromServerHistory: boolean;
|
|
|
|
}
|
|
|
|
|
|
|
|
interface IServerInit extends Action {
|
|
|
|
previousServer: string;
|
|
|
|
}
|
|
|
|
|
2023-10-19 13:38:57 +00:00
|
|
|
export type TActionServer = ISelectServerAction & ISelectServerSuccess & IServerRequestAction & IServerInit;
|
2022-01-18 15:59:43 +00:00
|
|
|
|
2023-10-19 13:38:57 +00:00
|
|
|
export function selectServerRequest(
|
|
|
|
server: string,
|
|
|
|
version?: string,
|
|
|
|
fetchVersion = true,
|
|
|
|
changeServer = false
|
|
|
|
): ISelectServerAction {
|
2022-01-18 15:59:43 +00:00
|
|
|
return {
|
|
|
|
type: SERVER.SELECT_REQUEST,
|
|
|
|
server,
|
|
|
|
version,
|
|
|
|
fetchVersion,
|
|
|
|
changeServer
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2023-10-19 13:38:57 +00:00
|
|
|
export function selectServerSuccess({
|
|
|
|
server,
|
|
|
|
version,
|
|
|
|
name
|
|
|
|
}: {
|
|
|
|
server: string;
|
|
|
|
version: string;
|
|
|
|
name: string;
|
|
|
|
}): ISelectServerSuccess {
|
2022-01-18 15:59:43 +00:00
|
|
|
return {
|
|
|
|
type: SERVER.SELECT_SUCCESS,
|
|
|
|
server,
|
2023-10-19 13:38:57 +00:00
|
|
|
version,
|
|
|
|
name
|
2022-01-18 15:59:43 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
export function selectServerFailure(): Action {
|
|
|
|
return {
|
|
|
|
type: SERVER.SELECT_FAILURE
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2023-10-19 13:38:57 +00:00
|
|
|
export function serverRequest(server: string, username: string | null = null, fromServerHistory = false): IServerRequestAction {
|
2022-01-18 15:59:43 +00:00
|
|
|
return {
|
|
|
|
type: SERVER.REQUEST,
|
|
|
|
server,
|
|
|
|
username,
|
|
|
|
fromServerHistory
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
export function serverSuccess(): Action {
|
|
|
|
return {
|
|
|
|
type: SERVER.SUCCESS
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2023-10-19 13:38:57 +00:00
|
|
|
export function serverFailure(): Action {
|
2022-01-18 15:59:43 +00:00
|
|
|
return {
|
2023-10-19 13:38:57 +00:00
|
|
|
type: SERVER.FAILURE
|
2022-01-18 15:59:43 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
export function serverInitAdd(previousServer: string): IServerInit {
|
|
|
|
return {
|
|
|
|
type: SERVER.INIT_ADD,
|
|
|
|
previousServer
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
export function serverFinishAdd(): Action {
|
|
|
|
return {
|
|
|
|
type: SERVER.FINISH_ADD
|
|
|
|
};
|
|
|
|
}
|