From d033042e0b4fb8d45c22ff91780984fab7538129 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elias=20M=C3=BCller?= <elias@elias-mueller.com> Date: Mon, 1 Jan 2024 01:36:14 +0100 Subject: [PATCH] #1 Fixed chat timestamps not always working correctly --- lib/view/pages/talk/chatView.dart | 8 ++++++-- lib/view/pages/talk/components/chatTextfield.dart | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/view/pages/talk/chatView.dart b/lib/view/pages/talk/chatView.dart index 29e696b..a2c0c82 100644 --- a/lib/view/pages/talk/chatView.dart +++ b/lib/view/pages/talk/chatView.dart @@ -38,7 +38,11 @@ class _ChatViewState extends State<ChatView> { void _query({bool renew = false}) { Provider.of<ChatProps>(context, listen: false).setQueryToken(widget.room.token); } - + + bool isSameDay(DateTime date1, DateTime date2) { + return date1.year == date2.year && date1.month == date2.month && date1.day == date2.day; + } + @override Widget build(BuildContext context) { return Consumer<ChatProps>( @@ -53,7 +57,7 @@ class _ChatViewState extends State<ChatView> { if(element.systemMessage.contains("reaction")) return; - if(elementDate.weekday != lastDate.weekday) { + if(!isSameDay(elementDate, lastDate)) { lastDate = elementDate; messages.add(ChatBubble( context: context, diff --git a/lib/view/pages/talk/components/chatTextfield.dart b/lib/view/pages/talk/components/chatTextfield.dart index c3170fb..9aea0b9 100644 --- a/lib/view/pages/talk/components/chatTextfield.dart +++ b/lib/view/pages/talk/components/chatTextfield.dart @@ -154,7 +154,7 @@ class _ChatTextfieldState extends State<ChatTextfield> { ), cursorColor: Colors.white, onChanged: (String text) { - if(text == "marbot marbot marbot") { + if(text.trim().toLowerCase() == "marbot marbot marbot") { var newText = "Roboter sind cool und so, aber marbots sind besser!"; _textBoxController.text = newText; text = newText;