refactor: Rename LogoutUseCase, call with invoke. (#968)
This commit is contained in:
parent
03cb6c313e
commit
ea53b68b3f
|
@ -116,7 +116,7 @@ import app.pachli.interfaces.ActionButtonActivity
|
||||||
import app.pachli.pager.MainPagerAdapter
|
import app.pachli.pager.MainPagerAdapter
|
||||||
import app.pachli.updatecheck.UpdateCheck
|
import app.pachli.updatecheck.UpdateCheck
|
||||||
import app.pachli.usecase.DeveloperToolsUseCase
|
import app.pachli.usecase.DeveloperToolsUseCase
|
||||||
import app.pachli.usecase.LogoutUsecase
|
import app.pachli.usecase.LogoutUseCase
|
||||||
import app.pachli.util.getDimension
|
import app.pachli.util.getDimension
|
||||||
import app.pachli.util.updateShortcuts
|
import app.pachli.util.updateShortcuts
|
||||||
import at.connyduck.calladapter.networkresult.fold
|
import at.connyduck.calladapter.networkresult.fold
|
||||||
|
@ -184,7 +184,7 @@ class MainActivity : BottomSheetActivity(), ActionButtonActivity, MenuProvider {
|
||||||
lateinit var cacheUpdater: CacheUpdater
|
lateinit var cacheUpdater: CacheUpdater
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
lateinit var logoutUsecase: LogoutUsecase
|
lateinit var logout: LogoutUseCase
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
lateinit var draftsAlert: DraftsAlert
|
lateinit var draftsAlert: DraftsAlert
|
||||||
|
@ -1039,7 +1039,7 @@ class MainActivity : BottomSheetActivity(), ActionButtonActivity, MenuProvider {
|
||||||
binding.composeButton.hide()
|
binding.composeButton.hide()
|
||||||
|
|
||||||
lifecycleScope.launch {
|
lifecycleScope.launch {
|
||||||
val otherAccountAvailable = logoutUsecase.logout()
|
val otherAccountAvailable = logout.invoke()
|
||||||
val intent = if (otherAccountAvailable) {
|
val intent = if (otherAccountAvailable) {
|
||||||
MainActivityIntent(this@MainActivity)
|
MainActivityIntent(this@MainActivity)
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -14,7 +14,7 @@ import dagger.hilt.android.qualifiers.ApplicationContext
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
import timber.log.Timber
|
import timber.log.Timber
|
||||||
|
|
||||||
class LogoutUsecase @Inject constructor(
|
class LogoutUseCase @Inject constructor(
|
||||||
@ApplicationContext private val context: Context,
|
@ApplicationContext private val context: Context,
|
||||||
private val api: MastodonApi,
|
private val api: MastodonApi,
|
||||||
private val timelineDao: TimelineDao,
|
private val timelineDao: TimelineDao,
|
||||||
|
@ -23,12 +23,12 @@ class LogoutUsecase @Inject constructor(
|
||||||
private val accountManager: AccountManager,
|
private val accountManager: AccountManager,
|
||||||
private val draftHelper: DraftHelper,
|
private val draftHelper: DraftHelper,
|
||||||
) {
|
) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Logs the current account out and clears all caches associated with it
|
* Logs the current account out and clears all caches associated with it
|
||||||
|
*
|
||||||
* @return true if the user is logged in with other accounts, false if it was the only one
|
* @return true if the user is logged in with other accounts, false if it was the only one
|
||||||
*/
|
*/
|
||||||
suspend fun logout(): Boolean {
|
suspend operator fun invoke(): Boolean {
|
||||||
accountManager.activeAccount?.let { activeAccount ->
|
accountManager.activeAccount?.let { activeAccount ->
|
||||||
|
|
||||||
// invalidate the oauth token, if we have the client id & secret
|
// invalidate the oauth token, if we have the client id & secret
|
Loading…
Reference in New Issue