diff --git a/composeApp/src/commonMain/composeResources/values/strings.xml b/composeApp/src/commonMain/composeResources/values/strings.xml index f214324c..8d4e87e4 100644 --- a/composeApp/src/commonMain/composeResources/values/strings.xml +++ b/composeApp/src/commonMain/composeResources/values/strings.xml @@ -309,6 +309,7 @@ The ceremony was abandoned. The group can hold one key together, split so that no single member holds it. Signing with it takes a quorum. The group has a shared key. + %1$s has a shared key. The recovery phrase (sometimes called a seed) is a list of 12 English words. It is the only way back to this profile: the key that signs as you is derived from it.\n\nOnly you have this phrase. Keep it private — nobody from Giza will ever ask you for it.\n\nDo not lose it. Write it down and keep it somewhere safe that is not this phone. If you lose both the phone and the phrase, this profile is gone for good. These are your keys. Keep them safe so they can keep unlocking this profile, even when you lose or change your phone. This device holds no phrase for the profile that is signed in. diff --git a/composeApp/src/commonMain/kotlin/mobi/giza/compose/ui/composable/DkgRitualScreen.kt b/composeApp/src/commonMain/kotlin/mobi/giza/compose/ui/composable/DkgRitualScreen.kt index e45bcd52..eca8ae8f 100644 --- a/composeApp/src/commonMain/kotlin/mobi/giza/compose/ui/composable/DkgRitualScreen.kt +++ b/composeApp/src/commonMain/kotlin/mobi/giza/compose/ui/composable/DkgRitualScreen.kt @@ -115,6 +115,7 @@ import mobi.giza.compose.resources.each_member_s_device_checks_the_combined_resu import mobi.giza.compose.resources.shared_key import mobi.giza.compose.resources.the_ceremony_was_abandoned import mobi.giza.compose.resources.the_group_has_a_shared_key +import mobi.giza.compose.resources.s_has_a_shared_key import mobi.giza.compose.resources.the_group_has_agreed_what_the_admin_room import mobi.giza.compose.resources.the_group_could_not_agree_what_the_admin import mobi.giza.compose.resources.the_group_is_agreeing_what_the_admin_room @@ -473,7 +474,7 @@ private fun StalledCeremonyCard( } @Composable -private fun RitualProgress( +internal fun RitualProgress( session: DkgSession, participantCount: Int, activeUserPublicKey: HexKey, @@ -599,7 +600,14 @@ private fun RitualProgress( verticalAlignment = Alignment.CenterVertically ) { Icon(Icons.Default.CheckCircle, contentDescription = Decorative) - Text(stringResource(Res.string.the_group_has_a_shared_key), style = MaterialTheme.typography.titleSmall) + // Named, as the transcript's line is: the same people may have made + // more than one group in this room (docs/nip17-multiple-ceremonies.md). + Text( + text = session.subject + ?.let { stringResource(Res.string.s_has_a_shared_key, it) } + ?: stringResource(Res.string.the_group_has_a_shared_key), + style = MaterialTheme.typography.titleSmall + ) } session.thresholdPublicKey?.let { thresholdPublicKey -> diff --git a/composeApp/src/jvmTest/kotlin/mobi/giza/compose/ui/composable/RitualProgressNameJvmTest.kt b/composeApp/src/jvmTest/kotlin/mobi/giza/compose/ui/composable/RitualProgressNameJvmTest.kt new file mode 100644 index 00000000..4b98fa63 --- /dev/null +++ b/composeApp/src/jvmTest/kotlin/mobi/giza/compose/ui/composable/RitualProgressNameJvmTest.kt @@ -0,0 +1,74 @@ +package mobi.giza.compose.ui.composable + +import androidx.compose.foundation.rememberScrollState +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.verticalScroll +import androidx.compose.ui.Modifier +import androidx.compose.ui.test.ExperimentalTestApi +import androidx.compose.ui.test.onNodeWithText +import androidx.compose.ui.test.runDesktopComposeUiTest +import mobi.giza.compose.database.model.DkgSession +import mobi.giza.compose.database.model.types.DkgRitualStage +import mobi.giza.compose.ui.theme.GizaTheme +import kotlin.test.Test + +/** + * A finished ceremony's screen names the group it made, as its transcript line does: + * the same people may have made more than one group in the room. + * docs/nip17-multiple-ceremonies.md. + */ +@OptIn(ExperimentalTestApi::class) +class RitualProgressNameJvmTest { + + private fun finished(subject: String?) = DkgSession( + id = "5e55".repeat(16), + chatRoomId = "c3a1".repeat(16), + coordinatorPublicKey = "b".repeat(64), + userPublicKey = "a".repeat(64), + threshold = 3, + participantCount = 3, + subject = subject, + stage = DkgRitualStage.COMPLETE, + hostPublicKey = "02" + "11".repeat(32), + round1Random = "aa".repeat(32), + round2AuxRandom = "bb".repeat(32), + thresholdPublicKey = "03" + "ae".repeat(32), + ) + + private fun render(session: DkgSession, text: String) = + runDesktopComposeUiTest(width = 400, height = 1600) { + setContent { + GizaTheme { + Column(Modifier.verticalScroll(rememberScrollState())) { + RitualProgress( + session = session, + participantCount = 3, + activeUserPublicKey = "a".repeat(64), + members = emptyList(), + hostKeyParticipants = emptySet(), + round1Participants = emptySet(), + round2Participants = emptySet(), + isActionPending = false, + adminGroupBlockedOn = emptyList(), + keyStateSession = null, + isKeyStateSigned = true, + isRoomCreated = true, + parentChatRoomId = null, + isCertified = false, + certificateSession = null, + onProposeBirthCertificate = {}, + onProposeKeyState = {}, + onCreateAdminGroup = {}, + ) + } + } + } + onNodeWithText(text).assertExists() + } + + @Test + fun `a finished group is named`() = render(finished("Agora"), "Agora has a shared key.") + + @Test + fun `a ceremony from before names keeps its words`() = render(finished(null), "The group has a shared key.") +}