Moved fields limit to gamedig widget

This commit is contained in:
fredodiable 2023-07-27 01:33:35 +02:00
parent 0fcfaea47e
commit 2f94c1ec2d
2 changed files with 5 additions and 7 deletions

View File

@ -296,13 +296,6 @@ export function cleanServiceGroups(groups) {
} = cleanedService.widget; } = cleanedService.widget;
let fieldsList = fields; let fieldsList = fields;
const MAX_ALLOWED_FIELDS = 4;
// Limits max number of displayed fields
if (fieldsList != null && fieldsList.length > MAX_ALLOWED_FIELDS) {
fieldsList = fieldsList.slice(0, MAX_ALLOWED_FIELDS);
}
if (typeof fields === 'string') { if (typeof fields === 'string') {
try { JSON.parse(fields) } try { JSON.parse(fields) }
catch (e) { catch (e) {

View File

@ -17,6 +17,11 @@ export default function Component({ service }) {
if (widget.fields == null || widget.fields.length === 0) { if (widget.fields == null || widget.fields.length === 0) {
widget.fields = ["map", "currentPlayers", "ping"]; widget.fields = ["map", "currentPlayers", "ping"];
} }
const MAX_ALLOWED_FIELDS = 4;
// Limits max number of displayed fields
if (widget.fields != null && widget.fields.length > MAX_ALLOWED_FIELDS) {
widget.fields = widget.fields.slice(0, MAX_ALLOWED_FIELDS);
}
if (!serverData) { if (!serverData) {
return ( return (