|
@@ -21,6 +21,7 @@
|
|
|
|
|
|
package com.nextcloud.talk.ui.theme
|
|
|
|
|
|
+import android.annotation.SuppressLint
|
|
|
import android.content.Context
|
|
|
import com.nextcloud.talk.data.user.model.User
|
|
|
import com.nextcloud.talk.models.json.capabilities.Capabilities
|
|
@@ -32,12 +33,31 @@ internal class ServerThemeProviderImpl(
|
|
|
private val userProvider: CurrentUserProviderNew
|
|
|
) :
|
|
|
ServerThemeProvider {
|
|
|
+ // TODO move this logic to currentUserProvider or something
|
|
|
+ private var _currentUser: User? = null
|
|
|
+ private val currentUser: User
|
|
|
+ @SuppressLint("CheckResult")
|
|
|
+ get() {
|
|
|
+ return when (_currentUser) {
|
|
|
+ null -> {
|
|
|
+ // immediately get a result synchronously
|
|
|
+ _currentUser = userProvider.currentUser.blockingGet()
|
|
|
+ // start observable for auto-updates
|
|
|
+ userProvider.currentUserObservable.subscribe { _currentUser = it }
|
|
|
+ _currentUser!!
|
|
|
+ }
|
|
|
+ else -> {
|
|
|
+ _currentUser!!
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
override fun getServerThemeForUser(user: User): ServerTheme {
|
|
|
return getServerThemeForCapabilities(user.capabilities!!)
|
|
|
}
|
|
|
|
|
|
override fun getServerThemeForCurrentUser(): ServerTheme {
|
|
|
- return getServerThemeForUser(userProvider.currentUser.blockingGet())
|
|
|
+ return getServerThemeForUser(currentUser)
|
|
|
}
|
|
|
|
|
|
override fun getServerThemeForCapabilities(capabilities: Capabilities): ServerTheme {
|