diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/nests/room/lobby/NestLobbyScreen.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/nests/room/lobby/NestLobbyScreen.kt index 81c217c448..cb1f9d86e6 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/nests/room/lobby/NestLobbyScreen.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/nests/room/lobby/NestLobbyScreen.kt @@ -197,30 +197,17 @@ private fun NestLobbyContent( .consumeWindowInsets(padding) .imePadding(), ) { - // Same chat list shape as NestFullScreen: a reverse-layout - // LazyColumn keyed by note id. The lobby uses cached - // LocalCache notes instead of an active NestViewModel.chat, - // and stacks the room metadata (header, listener count, - // "Recent chat" label) above the oldest message so the - // user can scroll up through history into the room info. + RoomHeader(event, accountViewModel, nav) + CachedListenerCount(roomATag) + + // Reverse-layout LazyColumn keyed by note id, same shape as + // NestFullScreen's chat list. The lobby reads cached + // LocalCache notes instead of an active NestViewModel.chat. LazyColumn( - modifier = Modifier.weight(1f).fillMaxSize(), + modifier = Modifier.weight(1f).fillMaxWidth(), state = listState, reverseLayout = true, ) { - items( - items = messages, - key = { it.idHex }, - ) { note -> - ChatroomMessageCompose( - baseNote = note, - routeForLastRead = routeForLastRead, - accountViewModel = accountViewModel, - nav = nav, - onWantsToReply = nestScreenModel::reply, - onWantsToEditDraft = nestScreenModel::editFromDraft, - ) - } if (messages.isEmpty()) { item("chat-empty") { Text( @@ -233,19 +220,19 @@ private fun NestLobbyContent( ) } } - item("chat-header") { - Text( - text = stringRes(R.string.nest_lobby_recent_chat), - style = MaterialTheme.typography.titleSmall, - modifier = Modifier.padding(horizontal = 16.dp, vertical = 8.dp), + items( + items = messages, + key = { it.idHex }, + ) { note -> + ChatroomMessageCompose( + baseNote = note, + routeForLastRead = routeForLastRead, + accountViewModel = accountViewModel, + nav = nav, + onWantsToReply = nestScreenModel::reply, + onWantsToEditDraft = nestScreenModel::editFromDraft, ) } - item("listeners") { - CachedListenerCount(roomATag) - } - item("header") { - RoomHeader(event, accountViewModel, nav) - } } // The composer sits above the 3-button nav when the keyboard diff --git a/quartz/CLIENT.md b/quartz/CLIENT.md index c7d58b11db..99338a8821 100644 --- a/quartz/CLIENT.md +++ b/quartz/CLIENT.md @@ -357,6 +357,8 @@ results.forEach { (relay, success) -> 6. On disconnection, exponential backoff retries the connection 7. On reconnection, filters are re-sent and events re-delivered +`NostrClient` starts active by default and connects on demand — there's no need to call `client.connect()` at startup. That method only matters for resuming after a prior `disconnect()` (e.g., a user-toggled offline mode). Conversely, `client.disconnect()` is what you want when the app is going to background or being shut down: it tears down every socket and stops the auto-reconnect loop. + ### Subscription Flow ``` diff --git a/quartz/README.md b/quartz/README.md index 83f85c8745..48d4cf7e54 100644 --- a/quartz/README.md +++ b/quartz/README.md @@ -83,6 +83,8 @@ Notice that the `notes` flow is ready for the UI and automatically subscribes and unsubscribes to any group of relays and filters the user wants. Similarly, the `send` function updates both the local db and the relay. +`NostrClient` connects on-demand: the first `subscribe(...)` or `publish(...)` to a relay triggers the socket. There's no need to call `client.connect()` at startup — it's only useful for resuming after a prior `disconnect()`. + ## Building a reactive feed UI A feed screen reads from the view model's feed flow, which only updates when @@ -202,4 +204,4 @@ private fun NoteRow(handle: MutableStateFlow) { ``` Notice how each how also subscribe for changes. This is important to receive -updates from replaceable and addressable events. \ No newline at end of file +updates from replaceable and addressable events.