🐛 Fix chat last message displaying inconsistences

This commit is contained in:
LittleSheep 2025-02-26 00:29:35 +08:00
parent f746e06f65
commit 52ab1d0d10

View File

@ -290,10 +290,34 @@ class _ChatScreenState extends State<ChatScreen> {
], ],
), ),
subtitle: lastMessage != null subtitle: lastMessage != null
? Text( ? Row(
'${ud.getAccountFromCache(lastMessage.sender.accountId)?.nick}: ${lastMessage.body['text'] ?? 'Unable preview'}', children: [
maxLines: 1, Expanded(
overflow: TextOverflow.ellipsis, child: Text(
lastMessage.body['text'] ??
'Unable preview',
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
),
const Gap(4),
Text(
DateFormat(
lastMessage.createdAt.toLocal().day ==
DateTime.now().day
? 'HH:mm'
: lastMessage.createdAt
.toLocal()
.year ==
DateTime.now().year
? 'MM/dd'
: 'yy/MM/dd',
).format(lastMessage.createdAt.toLocal()),
style: GoogleFonts.robotoMono(
fontSize: 12,
),
),
],
) )
: Text( : Text(
channel.description, channel.description,
@ -336,6 +360,8 @@ class _ChatScreenState extends State<ChatScreen> {
'unknown'.tr()), 'unknown'.tr()),
backgroundColor: backgroundColor:
Theme.of(context).colorScheme.primary, Theme.of(context).colorScheme.primary,
textColor:
Theme.of(context).colorScheme.onPrimary,
), ),
const Gap(6), const Gap(6),
Expanded( Expanded(
@ -346,6 +372,7 @@ class _ChatScreenState extends State<ChatScreen> {
overflow: TextOverflow.ellipsis, overflow: TextOverflow.ellipsis,
), ),
), ),
const Gap(4),
Text( Text(
DateFormat( DateFormat(
lastMessage.createdAt.toLocal().day == lastMessage.createdAt.toLocal().day ==