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.updatecheck.UpdateCheck
|
||||
import app.pachli.usecase.DeveloperToolsUseCase
|
||||
import app.pachli.usecase.LogoutUsecase
|
||||
import app.pachli.usecase.LogoutUseCase
|
||||
import app.pachli.util.getDimension
|
||||
import app.pachli.util.updateShortcuts
|
||||
import at.connyduck.calladapter.networkresult.fold
|
||||
|
@ -184,7 +184,7 @@ class MainActivity : BottomSheetActivity(), ActionButtonActivity, MenuProvider {
|
|||
lateinit var cacheUpdater: CacheUpdater
|
||||
|
||||
@Inject
|
||||
lateinit var logoutUsecase: LogoutUsecase
|
||||
lateinit var logout: LogoutUseCase
|
||||
|
||||
@Inject
|
||||
lateinit var draftsAlert: DraftsAlert
|
||||
|
@ -1039,7 +1039,7 @@ class MainActivity : BottomSheetActivity(), ActionButtonActivity, MenuProvider {
|
|||
binding.composeButton.hide()
|
||||
|
||||
lifecycleScope.launch {
|
||||
val otherAccountAvailable = logoutUsecase.logout()
|
||||
val otherAccountAvailable = logout.invoke()
|
||||
val intent = if (otherAccountAvailable) {
|
||||
MainActivityIntent(this@MainActivity)
|
||||
} else {
|
||||
|
|
|
@ -14,7 +14,7 @@ import dagger.hilt.android.qualifiers.ApplicationContext
|
|||
import javax.inject.Inject
|
||||
import timber.log.Timber
|
||||
|
||||
class LogoutUsecase @Inject constructor(
|
||||
class LogoutUseCase @Inject constructor(
|
||||
@ApplicationContext private val context: Context,
|
||||
private val api: MastodonApi,
|
||||
private val timelineDao: TimelineDao,
|
||||
|
@ -23,12 +23,12 @@ class LogoutUsecase @Inject constructor(
|
|||
private val accountManager: AccountManager,
|
||||
private val draftHelper: DraftHelper,
|
||||
) {
|
||||
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
suspend fun logout(): Boolean {
|
||||
suspend operator fun invoke(): Boolean {
|
||||
accountManager.activeAccount?.let { activeAccount ->
|
||||
|
||||
// invalidate the oauth token, if we have the client id & secret
|
Loading…
Reference in New Issue