feat(audiorooms): prompt to add default server when user has none

When the + FAB is tapped on Audio Rooms and the user's kind:10112
nests-server list is empty (or has no http(s) entries), show an
AlertDialog offering to add the built-in default
(CreateAudioRoomViewModel.DEFAULT_SERVICE_URL — moq.nostrnests.com)
to their list, then continue into the create-room sheet.

Wired through the existing Account.sendNestsServersList path used by
the Settings screen's NestsServersViewModel.save(), so the resulting
kind:10112 propagates to the user's outbox identically. On signer/
network failure surface a toast and keep the dialog dismissed (the
user can retry from Settings).

If the user already has a usable server, behavior is unchanged — the
FAB opens the create-room sheet directly.

https://claude.ai/code/session_01RDpuki4t8StSg1CZcXnV5b
This commit is contained in:
Claude
2026-04-27 14:04:31 +00:00
parent 98202b63bc
commit eae28ab943
2 changed files with 65 additions and 1 deletions
@@ -21,7 +21,10 @@
package com.vitorpamplona.amethyst.ui.screen.loggedIn.audiorooms
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.material3.AlertDialog
import androidx.compose.material3.FloatingActionButton
import androidx.compose.material3.Text
import androidx.compose.material3.TextButton
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue
@@ -44,6 +47,7 @@ import com.vitorpamplona.amethyst.ui.navigation.navs.INav
import com.vitorpamplona.amethyst.ui.navigation.routes.Route
import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel
import com.vitorpamplona.amethyst.ui.screen.loggedIn.audiorooms.create.CreateAudioRoomSheet
import com.vitorpamplona.amethyst.ui.screen.loggedIn.audiorooms.create.CreateAudioRoomViewModel
import com.vitorpamplona.amethyst.ui.screen.loggedIn.audiorooms.datasource.AudioRoomsFilterAssemblerSubscription
import com.vitorpamplona.amethyst.ui.stringRes
@@ -69,7 +73,10 @@ fun AudioRoomsScreen(
WatchAccountForAudioRoomsScreen(audioRoomsFeedState = audioRoomsFeedContentState, accountViewModel = accountViewModel)
AudioRoomsFilterAssemblerSubscription(accountViewModel)
val nestsServers by accountViewModel.account.nestsServers.flow
.collectAsStateWithLifecycle()
var showCreateSheet by remember { mutableStateOf(false) }
var showSetupDialog by remember { mutableStateOf(false) }
DisappearingScaffold(
isInvertedLayout = false,
@@ -87,7 +94,13 @@ fun AudioRoomsScreen(
},
floatingButton = {
FloatingActionButton(
onClick = { showCreateSheet = true },
onClick = {
if (nestsServers.any { it.startsWith("http") }) {
showCreateSheet = true
} else {
showSetupDialog = true
}
},
shape = CircleShape,
) {
Icon(
@@ -119,6 +132,29 @@ fun AudioRoomsScreen(
}
}
if (showSetupDialog) {
SetUpAudioServerDialog(
defaultUrl = CreateAudioRoomViewModel.DEFAULT_SERVICE_URL,
onDismiss = { showSetupDialog = false },
onConfirm = {
showSetupDialog = false
accountViewModel.launchSigner {
try {
accountViewModel.account.sendNestsServersList(
listOf(CreateAudioRoomViewModel.DEFAULT_SERVICE_URL),
)
showCreateSheet = true
} catch (_: Throwable) {
accountViewModel.toastManager.toast(
R.string.audio_rooms,
R.string.audio_room_no_server_save_failed,
)
}
}
},
)
}
if (showCreateSheet) {
CreateAudioRoomSheet(
accountViewModel = accountViewModel,
@@ -127,6 +163,29 @@ fun AudioRoomsScreen(
}
}
@Composable
private fun SetUpAudioServerDialog(
defaultUrl: String,
onDismiss: () -> Unit,
onConfirm: () -> Unit,
) {
AlertDialog(
onDismissRequest = onDismiss,
title = { Text(stringRes(R.string.audio_room_no_server_title)) },
text = { Text(stringRes(R.string.audio_room_no_server_body, defaultUrl)) },
confirmButton = {
TextButton(onClick = onConfirm) {
Text(stringRes(R.string.audio_room_no_server_use_default))
}
},
dismissButton = {
TextButton(onClick = onDismiss) {
Text(stringRes(R.string.audio_room_no_server_cancel))
}
},
)
}
@Composable
fun WatchAccountForAudioRoomsScreen(
audioRoomsFeedState: FeedContentState,
+5
View File
@@ -556,6 +556,11 @@
<string name="audio_room_participant_unmute">Unmute</string>
<string name="audio_room_share_action">Share room</string>
<string name="audio_room_create_fab">Start space</string>
<string name="audio_room_no_server_title">Set up an audio server</string>
<string name="audio_room_no_server_body">You haven\'t picked an audio server yet. Add %1$s to your server list and continue?\n\nYou can change this later in Settings.</string>
<string name="audio_room_no_server_use_default">Use default</string>
<string name="audio_room_no_server_cancel">Cancel</string>
<string name="audio_room_no_server_save_failed">Couldn\'t save your audio server list. Try again.</string>
<string name="audio_room_create_title">Start a new audio room</string>
<string name="audio_room_create_field_room">Room name</string>
<string name="audio_room_create_field_summary">What\'s it about?</string>