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",
"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": {
"description": "Text displayed when the host is invalid",
"context": "Visible in the settings view",

View File

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