Fixed send button, now throw exception is message empty

This commit is contained in:
JHubi1 2024-06-03 16:46:58 +02:00
parent 7f26da7954
commit cafc161aac
No known key found for this signature in database
GPG Key ID: 7BF82570CBBBD050
2 changed files with 17 additions and 4 deletions

View File

@ -170,7 +170,7 @@
"description": "Text displayed when the host is being checked", "description": "Text displayed when the host is being checked",
"context": "Visible in the settings view" "context": "Visible in the settings view"
}, },
"settingsHostInvalid": "Issue: {type, select, url{Invalid URL} host{Invalid Host} other{Request Failed}}", "settingsHostInvalid": "Issue: {type, select, url{Invalid URL} host{Invalid Host} timeout{Request Failed. Server issues} other{Request Failed}}",
"@settingsHostInvalid": { "@settingsHostInvalid": {
"description": "Text displayed when the host is invalid", "description": "Text displayed when the host is invalid",
"context": "Visible in the settings view", "context": "Visible in the settings view",

View File

@ -171,6 +171,7 @@ class _MainAppState extends State<MainApp> {
bool menuVisible = false; bool menuVisible = false;
int tipId = Random().nextInt(5); int tipId = Random().nextInt(5);
bool sendable = false;
List<Widget> sidebar(BuildContext context, Function setState) { List<Widget> sidebar(BuildContext context, Function setState) {
return List.from([ return List.from([
@ -1147,6 +1148,9 @@ class _MainAppState extends State<MainApp> {
} }
} }
if (chatAllowed) return; if (chatAllowed) return;
if (text.trim() == "") {
throw Exception();
}
messages.insert( messages.insert(
0, 0,
types.TextMessage( types.TextMessage(
@ -1168,6 +1172,9 @@ class _MainAppState extends State<MainApp> {
) )
.timeout(const Duration(seconds: 15)); .timeout(const Duration(seconds: 15));
if (chatAllowed) return; if (chatAllowed) return;
if (request.message!.content.trim() == "") {
throw Exception();
}
messages.insert( messages.insert(
0, 0,
types.TextMessage( types.TextMessage(
@ -1496,10 +1503,16 @@ class _MainAppState extends State<MainApp> {
l10n: ChatL10nEn( l10n: ChatL10nEn(
inputPlaceholder: AppLocalizations.of(context)! inputPlaceholder: AppLocalizations.of(context)!
.messageInputPlaceholder), .messageInputPlaceholder),
inputOptions: const InputOptions( inputOptions: InputOptions(
keyboardType: TextInputType.multiline, keyboardType: TextInputType.multiline,
sendButtonVisibilityMode: onTextChanged: (p0) {
SendButtonVisibilityMode.always), setState(() {
sendable = p0.trim().isNotEmpty;
});
},
sendButtonVisibilityMode: (sendable)
? SendButtonVisibilityMode.always
: SendButtonVisibilityMode.hidden),
user: user, user: user,
hideBackgroundOnEmojiMessages: false, hideBackgroundOnEmojiMessages: false,
theme: (Theme.of(context).brightness == Brightness.light) theme: (Theme.of(context).brightness == Brightness.light)