Update API around brandColor.
This commit is contained in:
committed by
Benoit Marty
parent
71c853d1a7
commit
64ff19c808
Submodule enterprise updated: c5465c9579...51fe0a48eb
@@ -23,7 +23,7 @@ interface EnterpriseService {
|
||||
* Override the brand color.
|
||||
* @param brandColor the color in hex format (#RRGGBBAA or #RRGGBB), or null to reset to default.
|
||||
*/
|
||||
fun overrideBrandColor(brandColor: String?)
|
||||
suspend fun overrideBrandColor(brandColor: String?)
|
||||
|
||||
@Composable
|
||||
fun semanticColorsLight(): State<SemanticColors>
|
||||
|
||||
@@ -32,7 +32,7 @@ class DefaultEnterpriseService : EnterpriseService {
|
||||
override fun defaultHomeserverList(): List<String> = emptyList()
|
||||
override suspend fun isAllowedToConnectToHomeserver(homeserverUrl: String) = true
|
||||
|
||||
override fun overrideBrandColor(brandColor: String?) = Unit
|
||||
override suspend fun overrideBrandColor(brandColor: String?) = Unit
|
||||
|
||||
@Composable
|
||||
override fun semanticColorsLight(): State<SemanticColors> {
|
||||
|
||||
@@ -42,7 +42,7 @@ class FakeEnterpriseService(
|
||||
isAllowedToConnectToHomeserverResult(homeserverUrl)
|
||||
}
|
||||
|
||||
override fun overrideBrandColor(brandColor: String?) {
|
||||
override suspend fun overrideBrandColor(brandColor: String?) = simulateLongTask {
|
||||
overrideBrandColorResult(brandColor)
|
||||
}
|
||||
|
||||
|
||||
@@ -135,7 +135,7 @@ class DeveloperSettingsPresenter(
|
||||
}
|
||||
appPreferencesStore.setTracingLogPacks(currentPacks)
|
||||
}
|
||||
is DeveloperSettingsEvents.ChangeBrandColor -> {
|
||||
is DeveloperSettingsEvents.ChangeBrandColor -> coroutineScope.launch {
|
||||
showColorPicker = false
|
||||
val color = event.color?.value?.toHexString(HexFormat.UpperCase)?.substring(2, 8)
|
||||
enterpriseService.overrideBrandColor(color)
|
||||
|
||||
@@ -203,6 +203,7 @@ class DeveloperSettingsPresenterTest {
|
||||
assertThat(awaitItem().showColorPicker).isTrue()
|
||||
initialState.eventSink(DeveloperSettingsEvents.ChangeBrandColor(Color.Green))
|
||||
assertThat(awaitItem().showColorPicker).isFalse()
|
||||
skipItems(1)
|
||||
overrideBrandColorResult.assertions().isCalledOnce()
|
||||
.with(value("00FF00"))
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,4 +11,5 @@ data class ElementWellKnown(
|
||||
val registrationHelperUrl: String?,
|
||||
val enforceElementPro: Boolean?,
|
||||
val rageshakeUrl: String?,
|
||||
val brandColor: String?,
|
||||
)
|
||||
|
||||
@@ -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,
|
||||
)
|
||||
|
||||
@@ -15,6 +15,7 @@ internal fun InternalElementWellKnown.map() = ElementWellKnown(
|
||||
registrationHelperUrl = registrationHelperUrl,
|
||||
enforceElementPro = enforceElementPro,
|
||||
rageshakeUrl = rageshakeUrl,
|
||||
brandColor = brandColor,
|
||||
)
|
||||
|
||||
internal fun InternalWellKnown.map() = WellKnown(
|
||||
|
||||
@@ -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,
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user