From 598256639b0e4829e82057eeb0d41554e7532c2d Mon Sep 17 00:00:00 2001 From: nrobi144 Date: Thu, 19 Mar 2026 07:31:27 +0200 Subject: [PATCH] =?UTF-8?q?fix(chats):=20share=20single=20DesktopIAccount?= =?UTF-8?q?=20across=20deck=20=E2=80=94=20DMs=20now=20visible?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit DeckColumnContainer was creating its own DesktopIAccount (and ChatroomList) for the Messages column, while Main.kt created a separate one for DM relay subscriptions. Events were added to one ChatroomList but the UI read from the other, so DMs never appeared. Fix: thread the single iAccount from Main.kt through DeckLayout → DeckColumnContainer → RootContent → DesktopMessagesScreen. Removed the duplicate DesktopIAccount and DmSendTracker creation from RootContent. Audited all other deck column types — no similar instance duplication found. Co-Authored-By: Claude Opus 4.6 (1M context) --- .../com/vitorpamplona/amethyst/desktop/Main.kt | 7 +++---- .../amethyst/desktop/ui/deck/DeckColumnContainer.kt | 12 +++--------- .../amethyst/desktop/ui/deck/DeckLayout.kt | 2 ++ .../amethyst/desktop/ui/deck/SinglePaneLayout.kt | 2 ++ 4 files changed, 10 insertions(+), 13 deletions(-) diff --git a/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/Main.kt b/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/Main.kt index 0faa64174..e61a8bfb4 100644 --- a/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/Main.kt +++ b/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/Main.kt @@ -655,16 +655,13 @@ fun MainContent( if (reactionNote.event == null) { reactionNote.loadEvent(innerEvent, reactionAuthor, emptyList()) } - // Attach reaction to the target message note innerEvent.originalPost().forEach { targetId -> val targetNote = localCache.getNoteIfExists(targetId) targetNote?.addReaction(reactionNote) } } - else -> { - println("Unhandled NIP-17 inner event: ${innerEvent.kind}") - } + else -> {} } } } @@ -704,6 +701,7 @@ fun MainContent( localCache = localCache, accountManager = accountManager, account = account, + iAccount = iAccount, nwcConnection = nwcConnection, subscriptionsCoordinator = subscriptionsCoordinator, appScope = appScope, @@ -740,6 +738,7 @@ fun MainContent( localCache = localCache, accountManager = accountManager, account = account, + iAccount = iAccount, nwcConnection = nwcConnection, subscriptionsCoordinator = subscriptionsCoordinator, appScope = appScope, diff --git a/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/ui/deck/DeckColumnContainer.kt b/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/ui/deck/DeckColumnContainer.kt index b59abab0f..7a7d8847f 100644 --- a/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/ui/deck/DeckColumnContainer.kt +++ b/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/ui/deck/DeckColumnContainer.kt @@ -55,7 +55,6 @@ import com.vitorpamplona.amethyst.desktop.ui.ThreadScreen import com.vitorpamplona.amethyst.desktop.ui.UserProfileScreen import com.vitorpamplona.amethyst.desktop.ui.ZapFeedback import com.vitorpamplona.amethyst.desktop.ui.chats.DesktopMessagesScreen -import com.vitorpamplona.amethyst.desktop.ui.chats.DmSendTracker import com.vitorpamplona.quartz.nip47WalletConnect.Nip47WalletConnect.Nip47URINorm import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.flow.MutableStateFlow @@ -90,6 +89,7 @@ fun DeckColumnContainer( localCache: DesktopLocalCache, accountManager: AccountManager, account: AccountState.LoggedIn, + iAccount: DesktopIAccount, nwcConnection: Nip47URINorm?, subscriptionsCoordinator: DesktopRelaySubscriptionsCoordinator, appScope: CoroutineScope, @@ -129,6 +129,7 @@ fun DeckColumnContainer( localCache = localCache, accountManager = accountManager, account = account, + iAccount = iAccount, nwcConnection = nwcConnection, subscriptionsCoordinator = subscriptionsCoordinator, appScope = appScope, @@ -170,6 +171,7 @@ internal fun RootContent( localCache: DesktopLocalCache, accountManager: AccountManager, account: AccountState.LoggedIn, + iAccount: DesktopIAccount, nwcConnection: Nip47URINorm?, subscriptionsCoordinator: DesktopRelaySubscriptionsCoordinator, appScope: CoroutineScope, @@ -202,14 +204,6 @@ internal fun RootContent( } DeckColumnType.Messages -> { - val dmSendTracker = - remember(relayManager) { - DmSendTracker(relayManager.client) - } - val iAccount = - remember(account, localCache, relayManager, dmSendTracker) { - DesktopIAccount(account, localCache, relayManager, dmSendTracker, appScope) - } DesktopMessagesScreen( account = iAccount, cacheProvider = localCache, diff --git a/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/ui/deck/DeckLayout.kt b/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/ui/deck/DeckLayout.kt index 1df6bf135..519d93217 100644 --- a/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/ui/deck/DeckLayout.kt +++ b/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/ui/deck/DeckLayout.kt @@ -58,6 +58,7 @@ fun DeckLayout( localCache: DesktopLocalCache, accountManager: AccountManager, account: AccountState.LoggedIn, + iAccount: com.vitorpamplona.amethyst.desktop.model.DesktopIAccount, nwcConnection: Nip47URINorm?, subscriptionsCoordinator: DesktopRelaySubscriptionsCoordinator, appScope: CoroutineScope, @@ -109,6 +110,7 @@ fun DeckLayout( localCache = localCache, accountManager = accountManager, account = account, + iAccount = iAccount, nwcConnection = nwcConnection, subscriptionsCoordinator = subscriptionsCoordinator, appScope = appScope, diff --git a/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/ui/deck/SinglePaneLayout.kt b/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/ui/deck/SinglePaneLayout.kt index f18e56db2..ea458daa2 100644 --- a/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/ui/deck/SinglePaneLayout.kt +++ b/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/ui/deck/SinglePaneLayout.kt @@ -94,6 +94,7 @@ fun SinglePaneLayout( localCache: DesktopLocalCache, accountManager: AccountManager, account: AccountState.LoggedIn, + iAccount: com.vitorpamplona.amethyst.desktop.model.DesktopIAccount, nwcConnection: Nip47URINorm?, subscriptionsCoordinator: DesktopRelaySubscriptionsCoordinator, appScope: CoroutineScope, @@ -167,6 +168,7 @@ fun SinglePaneLayout( localCache = localCache, accountManager = accountManager, account = account, + iAccount = iAccount, nwcConnection = nwcConnection, subscriptionsCoordinator = subscriptionsCoordinator, appScope = appScope,