From 50a5a8712d65fb33f18636375cf19ecc38501ba3 Mon Sep 17 00:00:00 2001 From: Wing <44992537+wingio@users.noreply.github.com> Date: Mon, 4 Dec 2023 20:12:22 -0500 Subject: [PATCH] Fix reply mentions not getting removed occasionally --- app/src/main/java/xyz/wingio/dimett/utils/Utils.kt | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/xyz/wingio/dimett/utils/Utils.kt b/app/src/main/java/xyz/wingio/dimett/utils/Utils.kt index f613ef0..806fda0 100644 --- a/app/src/main/java/xyz/wingio/dimett/utils/Utils.kt +++ b/app/src/main/java/xyz/wingio/dimett/utils/Utils.kt @@ -51,12 +51,20 @@ fun getLogger(): Logger = GlobalContext.get().get(named("default")) fun String.toAnnotatedString() = AnnotatedString(this) +/** + * Removes the mention for the replied user from the start of the text + */ fun processPostContent(post: Post): String { val repliedTo = post.mentions.firstOrNull { mention -> mention.id == post.userRepliedTo } return post.content?.plain?.run { - if (repliedTo != null) replaceFirst("@${repliedTo.username} ", "") else this + if (repliedTo != null) + this + .replaceFirst("@${repliedTo.username} ", "") + .replaceFirst("@${repliedTo.acct}", "") + else + this } ?: "" }