From 9fa1d769f9cc8b0c66af62ead0cde34ad3bfb802 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 24 Jul 2026 19:38:11 +0000 Subject: [PATCH] refactor: drop cachedModificationEventsForNote, now a redundant alias MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It existed to serve observeEdits a cheap synchronous value (an LRU read) distinct from the expensive IO-only findLatestModificationForNote cache scan. Since edits fold from Note.edits, findLatestModificationForNote is itself cheap and thread-safe, and cachedModificationEventsForNote had become a plain alias for it. observeEdits now calls findLatestModificationForNote directly — the same function observeNoteModifications already uses — and the LocalCache + AccountViewModel aliases are removed. Co-Authored-By: Claude Opus 4.8 Claude-Session: https://claude.ai/code/session_013HdLnAa4Pa1pFV9FTYVTB6 --- .../main/java/com/vitorpamplona/amethyst/model/LocalCache.kt | 2 -- .../main/java/com/vitorpamplona/amethyst/ui/note/NoteCompose.kt | 2 +- .../amethyst/ui/screen/loggedIn/AccountViewModel.kt | 2 -- 3 files changed, 1 insertion(+), 5 deletions(-) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/LocalCache.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/LocalCache.kt index 5c7a3909a5..c86b7d0c82 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/LocalCache.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/LocalCache.kt @@ -3268,8 +3268,6 @@ object LocalCache : ILocalCache, ICacheProvider { }.sortedWith(compareBy({ it.createdAt() }, { it.idHex })) } - fun cachedModificationEventsForNote(note: Note): List = findLatestModificationForNote(note) - /** * The kind-40003 Buzz edit currently overlaying [note], or null when unedited. Like every other * edit kind, only the ORIGINAL message author's edits count — the send side already gates Edit to diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/NoteCompose.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/NoteCompose.kt index b7d1b0a352..d1326aed5a 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/NoteCompose.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/NoteCompose.kt @@ -2062,7 +2062,7 @@ fun observeEdits( remember(baseNote.idHex) { // Edits are anchored on the note (Note.edits), so the current set is readable synchronously // (no cache scan) — start Empty or Loaded, never Loading. - val cached = accountViewModel.cachedModificationEventsForNote(baseNote) + val cached = LocalCache.findLatestModificationForNote(baseNote) mutableStateOf( if (cached.isEmpty()) { GenericLoadable.Empty() diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/AccountViewModel.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/AccountViewModel.kt index 8bc5440009..73c94e020b 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/AccountViewModel.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/AccountViewModel.kt @@ -2037,8 +2037,6 @@ class AccountViewModel( fun getAddressableNoteIfExists(key: Address): AddressableNote? = LocalCache.getAddressableNoteIfExists(key) - fun cachedModificationEventsForNote(note: Note): List = LocalCache.cachedModificationEventsForNote(note) - fun checkGetOrCreatePublicChatChannel(key: HexKey): PublicChatChannel = LocalCache.getOrCreatePublicChatChannel(key) fun checkGetOrCreateLiveActivityChannel(key: Address): LiveActivitiesChannel = LocalCache.getOrCreateLiveChannel(key)