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 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RcWSCNMTVcvKMXo7xA2hue
This commit is contained in:
Claude
2026-07-27 20:17:07 +00:00
parent 8283b22c2f
commit 89add9d053
3 changed files with 3 additions and 7 deletions
@@ -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)
@@ -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()
@@ -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<User>? = null,
var eTags: List<Note>? = 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<HexKey>()
val directMentionsNotes = mutableSetOf<Note>()