mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2026-08-06 06:44:37 +00:00
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:
@@ -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)
|
||||
|
||||
+1
-1
@@ -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>()
|
||||
|
||||
Reference in New Issue
Block a user