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

@ -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>

View file

@ -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> {

View file

@ -42,7 +42,7 @@ class FakeEnterpriseService(
isAllowedToConnectToHomeserverResult(homeserverUrl)
}
override fun overrideBrandColor(brandColor: String?) {
override suspend fun overrideBrandColor(brandColor: String?) = simulateLongTask {
overrideBrandColorResult(brandColor)
}

View file

@ -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)

View file

@ -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"))
}