diff --git a/lib/view/widget/note_summary.dart b/lib/view/widget/note_summary.dart index a05536c0..7e21591a 100644 --- a/lib/view/widget/note_summary.dart +++ b/lib/view/widget/note_summary.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; +import 'package:misskey_dart/misskey_dart.dart'; import '../../i18n/strings.g.dart'; import '../../model/account.dart'; @@ -19,6 +20,32 @@ class NoteSummary extends ConsumerWidget { final String noteId; final void Function()? onTap; + String getNoteSummary( + BuildContext context, + Note note, { + bool detailed = true, + }) { + return [ + if (note.cw case final cw?) + cw + else if (note.text case final text?) + text.replaceAll('\n', ' '), + if (note.fileIds.isNotEmpty) + '(${t.misskey.withNFiles(n: note.fileIds.length)})', + if (note.poll != null) '(${t.misskey.poll})', + if (note.replyId != null) + if (note.reply case final reply? when detailed) + 'RE: ${getNoteSummary(context, reply, detailed: false)}' + else + 'RE: ...', + if (note.renoteId != null) + if (note.renote case final renote? when detailed) + 'RE: ${getNoteSummary(context, renote, detailed: false)}' + else + 'RE: ...', + ].join(' '); + } + @override Widget build(BuildContext context, WidgetRef ref) { final note = ref.watch(noteProvider(account, noteId)); @@ -32,13 +59,7 @@ class NoteSummary extends ConsumerWidget { onTap: onTap, child: Mfm( account: account, - text: [ - if (note.text != null) note.text!.replaceAll('\n', ' '), - if (note.fileIds.isNotEmpty) - '(${t.misskey.withNFiles(n: note.fileIds.length)})', - if (note.poll != null) '(${t.misskey.poll})', - if (note.replyId != null) 'RE: ...', - ].join(' '), + text: getNoteSummary(context, note), simple: true, emojis: note.emojis, author: note.user,