From 89add9d053d9b4eccb024d5a2df8cf8917cdf7e2 Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 27 Jul 2026 20:17:07 +0000 Subject: [PATCH] refactor(chat): require an explicit Dao on NewMessageTagger Drop the `dao = LocalCache` default; the two callers without an AccountViewModel now pass `dao = LocalCache` explicitly. Co-Authored-By: Claude Opus 4.8 Claude-Session: https://claude.ai/code/session_01RcWSCNMTVcvKMXo7xA2hue --- .../main/java/com/vitorpamplona/amethyst/model/Account.kt | 2 +- .../service/notifications/NotificationReplyReceiver.kt | 2 +- .../vitorpamplona/amethyst/ui/actions/NewMessageTagger.kt | 6 +----- 3 files changed, 3 insertions(+), 7 deletions(-) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/Account.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/Account.kt index ee59b7ef36..ce0e99c7ff 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/Account.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/Account.kt @@ -2431,7 +2431,7 @@ class Account( // quick reply is notified (`p`) and their reference resolves. The reply-parent author is // already tagged by each builder below, so drop it from the body mentions to avoid a // duplicate `p`. - val tagger = NewMessageTagger(text) + val tagger = NewMessageTagger(text, dao = LocalCache) tagger.run() val mentions = tagger.pTags?.mapNotNull { it.pubkeyHex.takeIf { pk -> pk != rootEvent.pubKey } }.orEmpty() val finalText = appendMediaUrls(tagger.message, imetas) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/service/notifications/NotificationReplyReceiver.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/service/notifications/NotificationReplyReceiver.kt index b2191045bf..ecfd14b6ad 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/service/notifications/NotificationReplyReceiver.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/service/notifications/NotificationReplyReceiver.kt @@ -206,7 +206,7 @@ class NotificationReplyReceiver : BroadcastReceiver() { // (`p`) and linkable — the same enrichment the in-app composers do. The comment builders // already tag the reply-parent author, so drop it from the body mentions to avoid a // duplicate `p` (kind-1 doesn't auto-tag the parent, so nothing is lost there). - val tagger = NewMessageTagger(replyText) + val tagger = NewMessageTagger(replyText, dao = LocalCache) tagger.run() val mentions = tagger.pTags?.mapNotNull { pt -> pt.pubkeyHex.takeIf { it != targetEvent.pubKey } }.orEmpty() diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/actions/NewMessageTagger.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/actions/NewMessageTagger.kt index fa4ff1496d..78c89dc8e0 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/actions/NewMessageTagger.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/actions/NewMessageTagger.kt @@ -22,7 +22,6 @@ package com.vitorpamplona.amethyst.ui.actions import androidx.compose.runtime.Immutable import com.vitorpamplona.amethyst.model.AddressableNote -import com.vitorpamplona.amethyst.model.LocalCache import com.vitorpamplona.amethyst.model.Note import com.vitorpamplona.amethyst.model.User import com.vitorpamplona.quartz.nip01Core.core.Address @@ -45,10 +44,7 @@ class NewMessageTagger( var message: String, var pTags: List? = null, var eTags: List? = null, - // Defaults to LocalCache, which implements Dao directly, so callers with no AccountViewModel - // — model-layer sends, background receivers — can just omit it. UI callers still pass their - // AccountViewModel (also a Dao). - var dao: Dao = LocalCache, + var dao: Dao, ) { val directMentions = mutableSetOf() val directMentionsNotes = mutableSetOf()