Update API around brandColor.

This commit is contained in:
Benoit Marty 2025-10-20 14:42:53 +02:00 committed by Benoit Marty
parent b62382ffc7
commit 38908a42a2
12 changed files with 29 additions and 6 deletions

View file

@ -73,3 +73,15 @@ fun List<SessionData>.toUserList(): List<String> {
fun Flow<List<SessionData>>.toUserListFlow(): Flow<List<String>> {
return map { it.toUserList() }
}
/**
* @return a flow emitting the userId of the latest session if logged in, null otherwise.
*/
fun SessionStore.userIdFlow(): Flow<String?> {
return loggedInStateFlow().map {
when (it) {
is LoggedInState.LoggedIn -> it.sessionId
is LoggedInState.NotLoggedIn -> null
}
}
}

View file

@ -11,4 +11,5 @@ data class ElementWellKnown(
val registrationHelperUrl: String?,
val enforceElementPro: Boolean?,
val rageshakeUrl: String?,
val brandColor: String?,
)

View file

@ -27,4 +27,6 @@ data class InternalElementWellKnown(
val enforceElementPro: Boolean? = null,
@SerialName("rageshake_url")
val rageshakeUrl: String? = null,
@SerialName("brand_color")
val brandColor: String? = null,
)

View file

@ -15,6 +15,7 @@ internal fun InternalElementWellKnown.map() = ElementWellKnown(
registrationHelperUrl = registrationHelperUrl,
enforceElementPro = enforceElementPro,
rageshakeUrl = rageshakeUrl,
brandColor = brandColor,
)
internal fun InternalWellKnown.map() = WellKnown(

View file

@ -161,6 +161,7 @@ class DefaultSessionWellknownRetrieverTest {
registrationHelperUrl = null,
enforceElementPro = null,
rageshakeUrl = null,
brandColor = null,
)
)
getUrlLambda.assertions().isCalledOnce()
@ -175,7 +176,8 @@ class DefaultSessionWellknownRetrieverTest {
"""{
"registration_helper_url": "a_registration_url",
"enforce_element_pro": true,
"rageshake_url": "a_rageshake_url"
"rageshake_url": "a_rageshake_url",
"brand_color": "#FF0000"
}""".trimIndent().toByteArray()
)
}
@ -185,6 +187,7 @@ class DefaultSessionWellknownRetrieverTest {
registrationHelperUrl = "a_registration_url",
enforceElementPro = true,
rageshakeUrl = "a_rageshake_url",
brandColor = "#FF0000",
)
)
}
@ -208,6 +211,7 @@ class DefaultSessionWellknownRetrieverTest {
registrationHelperUrl = "a_registration_url",
enforceElementPro = true,
rageshakeUrl = "a_rageshake_url",
brandColor = null,
)
)
}

View file

@ -13,8 +13,10 @@ fun anElementWellKnown(
registrationHelperUrl: String? = null,
enforceElementPro: Boolean? = null,
rageshakeUrl: String? = null,
brandColor: String? = null,
) = ElementWellKnown(
registrationHelperUrl = registrationHelperUrl,
enforceElementPro = enforceElementPro,
rageshakeUrl = rageshakeUrl,
brandColor = brandColor,
)