Move chat sending related settings into their own component

This commit is contained in:
James Lyne 2021-01-07 17:24:21 +00:00
parent 823e9b4c99
commit 84c4f441c1
3 changed files with 22 additions and 14 deletions

View File

@ -39,10 +39,7 @@ import {useStore} from "@/store";
function buildServerConfig(response: any): DynmapServerConfig {
return {
version: response.dynmapversion || '',
allowChat: response.allowwebchat || false,
grayHiddenPlayers: response.grayplayerswhenhidden || false,
chatRequiresLogin: response['webchat-requires-login'] || false,
chatInterval: response['webchat-interval'] || 5,
defaultMap: response.defaultmap || undefined,
defaultWorld: response.defaultworld || undefined,
defaultZoom: response.defaultzoom || 0,
@ -52,7 +49,6 @@ function buildServerConfig(response: any): DynmapServerConfig {
showLayerControl: response.showlayercontrol || true,
title: response.title || 'Dynmap',
loginEnabled: response['login-enabled'] || false,
loginRequired: response.loginrequired || false,
maxPlayers: response.maxcount || 0,
hash: response.confighash || 0,
};
@ -189,6 +185,16 @@ function buildComponents(response: any): DynmapComponentConfig {
});
break;
case "chat":
if(response.allowwebchat) {
components.chatSending = {
loginRequired: response['webchat-requires-login'] || false,
maxLength: response['chatlengthlimit'] || 256,
cooldown: response['webchat-interval'] || 5,
}
}
break;
case "chatbox":
components.chatBox = {
allowUrlName: component.allowurlname || false,

15
src/dynmap.d.ts vendored
View File

@ -43,9 +43,6 @@ type DynmapUrlConfig = {
interface DynmapServerConfig {
version: string;
allowChat: boolean;
chatRequiresLogin: boolean;
chatInterval: number;
defaultMap?: string;
defaultWorld?: string;
defaultZoom: number;
@ -55,7 +52,6 @@ interface DynmapServerConfig {
showLayerControl: boolean;
title: string;
loginEnabled: boolean;
loginRequired: boolean;
maxPlayers: number;
grayHiddenPlayers: boolean;
hash: number;
@ -80,7 +76,8 @@ interface DynmapComponentConfig {
clockControl ?: ClockControlOptions;
linkControl: boolean;
logoControls: Array<LogoControlOptions>;
chatBox?: DynmapChatConfig;
chatBox?: DynmapChatBoxConfig;
chatSending?: DynmapChatSendingConfig;
chatBalloons: boolean;
}
@ -98,13 +95,19 @@ interface DynmapPlayerMarkersConfig {
smallFaces: boolean;
}
interface DynmapChatConfig {
interface DynmapChatBoxConfig {
allowUrlName: boolean;
showPlayerFaces: boolean;
messageLifetime: number;
messageHistory: number;
}
interface DynmapChatSendingConfig {
loginRequired: boolean;
maxLength: number;
cooldown: number;
}
interface DynmapWorld {
seaLevel: number;
name: string;

View File

@ -69,9 +69,6 @@ export const state: State = {
configuration: {
version: '',
allowChat: false,
chatRequiresLogin: false,
chatInterval: 5000,
defaultMap: '',
defaultWorld: '',
defaultZoom: 0,
@ -81,7 +78,6 @@ export const state: State = {
showLayerControl: true,
title: '',
loginEnabled: false,
loginRequired: false,
maxPlayers: 0,
grayHiddenPlayers: false,
hash: 0,
@ -135,6 +131,9 @@ export const state: State = {
//Optional "logo" controls.
logoControls: [],
//Chat message sending functionality
chatSending: undefined,
//Chat box
chatBox: undefined,