From e3570373d92f99a9e13db37c9d0ae3efd505e706 Mon Sep 17 00:00:00 2001 From: poppingmoon <63451158+poppingmoon@users.noreply.github.com> Date: Sat, 9 Nov 2024 13:51:21 +0900 Subject: [PATCH] fix: hide content from summary if cw is provided --- lib/view/widget/note_summary.dart | 35 ++++++++++++++++++++++++------- 1 file changed, 28 insertions(+), 7 deletions(-) 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,