markdown support for talk messages
This commit is contained in:
@@ -20,6 +20,7 @@ import '../../../../widget/confirm_dialog.dart';
|
||||
import '../../../../widget/debug/debug_tile.dart';
|
||||
import '../../../../widget/details_bottom_sheet.dart';
|
||||
import '../../../../widget/user_avatar.dart';
|
||||
import '../data/talk_markdown.dart';
|
||||
import '../talk_navigator.dart';
|
||||
|
||||
class ChatTile extends StatefulWidget {
|
||||
@@ -62,6 +63,18 @@ class _ChatTileState extends State<ChatTile> {
|
||||
|
||||
void _refreshList() => context.read<ChatListBloc>().refresh();
|
||||
|
||||
/// One-line preview of the last message: rich-object placeholders resolved,
|
||||
/// newlines flattened and — for Markdown messages — formatting stripped so
|
||||
/// the list shows readable text rather than raw markers.
|
||||
String _lastMessagePreview() {
|
||||
final last = widget.data.lastMessage;
|
||||
final text = RichObjectStringProcessor.parseToString(
|
||||
last.message.replaceAll('\n', ' '),
|
||||
last.messageParameters,
|
||||
);
|
||||
return last.markdown ? markdownToPlainText(text) : text;
|
||||
}
|
||||
|
||||
Future<void> _setCurrentAsRead() async {
|
||||
final token = widget.data.token;
|
||||
final lastId = widget.data.lastMessage.id;
|
||||
@@ -142,7 +155,7 @@ class _ChatTileState extends State<ChatTile> {
|
||||
),
|
||||
subtitle: Text(
|
||||
'${DateTime.fromMillisecondsSinceEpoch(widget.data.lastMessage.timestamp * 1000).formatRelative()}: '
|
||||
'${RichObjectStringProcessor.parseToString(widget.data.lastMessage.message.replaceAll("\n", " "), widget.data.lastMessage.messageParameters)}',
|
||||
'${_lastMessagePreview()}',
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
trailing: widget.data.unreadMessages <= 0
|
||||
|
||||
Reference in New Issue
Block a user