Fix logout button

This commit is contained in:
Kirill Kamakin
2022-04-08 21:54:43 +05:00
parent 0768842405
commit a3d320bb79
2 changed files with 5 additions and 7 deletions

View File

@@ -26,9 +26,7 @@ class AuthStorageImpl @Inject constructor(
.distinctUntilChanged()
private val singleThreadDispatcher = Executors.newSingleThreadExecutor().asCoroutineDispatcher()
override suspend fun setAuthHeader(authHeader: String?) {
putString(AUTH_HEADER_KEY, authHeader)
}
override suspend fun setAuthHeader(authHeader: String?) = putString(AUTH_HEADER_KEY, authHeader)
override suspend fun getAuthHeader(): String? = getString(AUTH_HEADER_KEY)
@@ -45,9 +43,7 @@ class AuthStorageImpl @Inject constructor(
value: String?
) = withContext(singleThreadDispatcher) {
Timber.v("putString() called with: key = $key, value = $value")
sharedPreferences.edit {
value?.let { putString(key, value) } ?: remove(key)
}
sharedPreferences.edit(commit = true) { putString(key, value) }
}
private suspend fun getString(key: String) = withContext(singleThreadDispatcher) {

View File

@@ -1,5 +1,6 @@
package gq.kirmanak.mealient.ui.activity
import androidx.lifecycle.LiveData
import androidx.lifecycle.ViewModel
import androidx.lifecycle.asLiveData
import androidx.lifecycle.viewModelScope
@@ -25,7 +26,8 @@ class MainActivityViewModel @Inject constructor(
authRepo.isAuthorizedFlow,
AuthenticationState::determineState
)
val authenticationStateLive = authenticationStateFlow.asLiveData()
val authenticationStateLive: LiveData<AuthenticationState>
get() = authenticationStateFlow.asLiveData()
fun logout() {
Timber.v("logout() called")