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 { function buildServerConfig(response: any): DynmapServerConfig {
return { return {
version: response.dynmapversion || '', version: response.dynmapversion || '',
allowChat: response.allowwebchat || false,
grayHiddenPlayers: response.grayplayerswhenhidden || false, grayHiddenPlayers: response.grayplayerswhenhidden || false,
chatRequiresLogin: response['webchat-requires-login'] || false,
chatInterval: response['webchat-interval'] || 5,
defaultMap: response.defaultmap || undefined, defaultMap: response.defaultmap || undefined,
defaultWorld: response.defaultworld || undefined, defaultWorld: response.defaultworld || undefined,
defaultZoom: response.defaultzoom || 0, defaultZoom: response.defaultzoom || 0,
@ -52,7 +49,6 @@ function buildServerConfig(response: any): DynmapServerConfig {
showLayerControl: response.showlayercontrol || true, showLayerControl: response.showlayercontrol || true,
title: response.title || 'Dynmap', title: response.title || 'Dynmap',
loginEnabled: response['login-enabled'] || false, loginEnabled: response['login-enabled'] || false,
loginRequired: response.loginrequired || false,
maxPlayers: response.maxcount || 0, maxPlayers: response.maxcount || 0,
hash: response.confighash || 0, hash: response.confighash || 0,
}; };
@ -189,6 +185,16 @@ function buildComponents(response: any): DynmapComponentConfig {
}); });
break; 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": case "chatbox":
components.chatBox = { components.chatBox = {
allowUrlName: component.allowurlname || false, allowUrlName: component.allowurlname || false,

15
src/dynmap.d.ts vendored
View File

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

View File

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