mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-11 18:53:06 +00:00
[MIRROR] rework tgui say long message handling (#10198)
Co-authored-by: Selis <12716288+ItsSelis@users.noreply.github.com> Co-authored-by: Kashargul <144968721+Kashargul@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
aae4063c27
commit
7e80962c40
@@ -130,4 +130,8 @@
|
|||||||
if(type == "entry" || type == "force")
|
if(type == "entry" || type == "force")
|
||||||
handle_entry(type, payload)
|
handle_entry(type, payload)
|
||||||
return TRUE
|
return TRUE
|
||||||
|
if(type == "lenwarn")
|
||||||
|
var/mlen = payload["length"]
|
||||||
|
var/maxlen = payload["maxlength"]
|
||||||
|
to_chat(client, span_warning(span_bold("Warning") + ": Message with [mlen] exceeded the maximum length of [maxlen]."))
|
||||||
return FALSE
|
return FALSE
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ export function TguiSay() {
|
|||||||
keyof typeof RADIO_PREFIXES | null
|
keyof typeof RADIO_PREFIXES | null
|
||||||
>(null);
|
>(null);
|
||||||
const [size, setSize] = useState(WindowSize.Small);
|
const [size, setSize] = useState(WindowSize.Small);
|
||||||
const [maxLength, setMaxLength] = useState(1024);
|
const [maxLength, setMaxLength] = useState(4096);
|
||||||
const [minimumHeight, setMinimumHeight] = useState(WindowSize.Small);
|
const [minimumHeight, setMinimumHeight] = useState(WindowSize.Small);
|
||||||
const [minimumWidth, setMinimumWidth] = useState(WindowSize.Width);
|
const [minimumWidth, setMinimumWidth] = useState(WindowSize.Width);
|
||||||
const [lightMode, setLightMode] = useState(false);
|
const [lightMode, setLightMode] = useState(false);
|
||||||
@@ -117,14 +117,21 @@ export function TguiSay() {
|
|||||||
const iterator = channelIterator.current;
|
const iterator = channelIterator.current;
|
||||||
const prefix = currentPrefix ?? '';
|
const prefix = currentPrefix ?? '';
|
||||||
|
|
||||||
if (value?.length && value.length < maxLength) {
|
if (value?.length) {
|
||||||
|
if (value.length < maxLength) {
|
||||||
chatHistory.current.add(value);
|
chatHistory.current.add(value);
|
||||||
Byond.sendMessage('entry', {
|
Byond.sendMessage('entry', {
|
||||||
channel: iterator.current(),
|
channel: iterator.current(),
|
||||||
entry: iterator.isSay() ? prefix + value : value,
|
entry: iterator.isSay() ? prefix + value : value,
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
Byond.sendMessage('lenwarn', {
|
||||||
|
length: value.length,
|
||||||
|
maxlength: maxLength,
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
handleClose();
|
handleClose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user