mirror of
https://github.com/zjs81/meshcore-open.git
synced 2026-04-20 22:13:48 +00:00
still use limitter but fix sending check on compressed text
This commit is contained in:
parent
cd24bb82a1
commit
612afc2fe8
2 changed files with 14 additions and 3 deletions
|
|
@ -1243,14 +1243,21 @@ class _ChannelChatScreenState extends State<ChannelChatScreen> {
|
|||
}
|
||||
|
||||
final maxBytes = maxChannelMessageBytes(connector.selfName);
|
||||
if (utf8.encode(messageText).length > maxBytes) {
|
||||
final smazEnabled = connector.isChannelSmazEnabled(widget.channel.index);
|
||||
final trimmed = messageText.trim();
|
||||
final isStructuredPayload =
|
||||
trimmed.startsWith('g:') || trimmed.startsWith('m:');
|
||||
final outboundText = (smazEnabled && !isStructuredPayload)
|
||||
? Smaz.encodeIfSmaller(messageText)
|
||||
: messageText;
|
||||
if (utf8.encode(outboundText).length > maxBytes) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(content: Text(context.l10n.chat_messageTooLong(maxBytes))),
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
connector.sendChannelMessage(widget.channel, messageText);
|
||||
connector.sendChannelMessage(widget.channel, outboundText);
|
||||
_textController.clear();
|
||||
_cancelReply();
|
||||
_textFieldFocusNode.requestFocus();
|
||||
|
|
|
|||
|
|
@ -597,7 +597,11 @@ class _ChatScreenState extends State<ChatScreen> {
|
|||
if (text.isEmpty) return;
|
||||
|
||||
final maxBytes = maxContactMessageBytes();
|
||||
if (utf8.encode(text).length > maxBytes) {
|
||||
final outboundText = connector.prepareContactOutboundText(
|
||||
widget.contact,
|
||||
text,
|
||||
);
|
||||
if (utf8.encode(outboundText).length > maxBytes) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(content: Text(context.l10n.chat_messageTooLong(maxBytes))),
|
||||
);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue