mirror of
https://github.com/element-hq/element-android
synced 2024-11-27 11:59:12 +03:00
IntegrationConfig: make preferred non null as we should at least get the default one
This commit is contained in:
parent
8f5589d3e1
commit
22e3b370e3
2 changed files with 7 additions and 7 deletions
|
@ -109,8 +109,8 @@ internal class IntegrationManager @Inject constructor(private val taskExecutor:
|
|||
accountDataDataSource
|
||||
.getLiveAccountDataEvent(UserAccountData.TYPE_WIDGETS)
|
||||
.observeNotNull(lifecycleOwner) {
|
||||
val integrationManager = it.getOrNull()?.asIntegrationManagerWidgetContent()
|
||||
val config = integrationManager?.extractIntegrationManagerConfig()
|
||||
val integrationManagerContent = it.getOrNull()?.asIntegrationManagerWidgetContent()
|
||||
val config = integrationManagerContent?.extractIntegrationManagerConfig()
|
||||
val accountConfig = currentConfigs.firstOrNull { currentConfig ->
|
||||
currentConfig.kind == IntegrationManagerConfig.Kind.ACCOUNT
|
||||
}
|
||||
|
@ -133,8 +133,9 @@ internal class IntegrationManager @Inject constructor(private val taskExecutor:
|
|||
}
|
||||
}
|
||||
|
||||
fun getPreferredConfig(): IntegrationManagerConfig? {
|
||||
return getOrderedConfigs().firstOrNull()
|
||||
fun getPreferredConfig(): IntegrationManagerConfig {
|
||||
// This can't be null as we should have at least the default one registered
|
||||
return getOrderedConfigs().first()
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -32,7 +32,7 @@ internal class DefaultWidgetURLBuilder @Inject constructor(private val integrati
|
|||
private val stringProvider: StringProvider
|
||||
) : IntegrationManager.Listener, WidgetURLBuilder {
|
||||
|
||||
private var currentConfig: IntegrationManagerConfig? = null
|
||||
private var currentConfig = integrationManager.getPreferredConfig()
|
||||
private var whiteListedUrls: List<String> = emptyList()
|
||||
|
||||
fun start() {
|
||||
|
@ -53,11 +53,10 @@ internal class DefaultWidgetURLBuilder @Inject constructor(private val integrati
|
|||
if (currentConfig != preferredConfig) {
|
||||
currentConfig = preferredConfig
|
||||
val defaultWhiteList = stringProvider.getStringArray(R.array.integrations_widgets_urls).asList()
|
||||
whiteListedUrls = when (preferredConfig?.kind) {
|
||||
whiteListedUrls = when (preferredConfig.kind) {
|
||||
IntegrationManagerConfig.Kind.DEFAULT -> defaultWhiteList
|
||||
IntegrationManagerConfig.Kind.ACCOUNT -> defaultWhiteList + preferredConfig.apiUrl
|
||||
IntegrationManagerConfig.Kind.HOMESERVER -> listOf(preferredConfig.apiUrl)
|
||||
else -> emptyList()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue