From ea53b68b3ffb92836fcf366ee3c2860b6ed70915 Mon Sep 17 00:00:00 2001 From: Nik Clayton Date: Thu, 3 Oct 2024 12:53:57 +0200 Subject: [PATCH] refactor: Rename LogoutUseCase, call with invoke. (#968) --- app/src/main/java/app/pachli/MainActivity.kt | 6 +++--- .../pachli/usecase/{LogoutUsecase.kt => LogoutUseCase.kt} | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) rename app/src/main/java/app/pachli/usecase/{LogoutUsecase.kt => LogoutUseCase.kt} (96%) diff --git a/app/src/main/java/app/pachli/MainActivity.kt b/app/src/main/java/app/pachli/MainActivity.kt index c5e2d29dd..161927ea1 100644 --- a/app/src/main/java/app/pachli/MainActivity.kt +++ b/app/src/main/java/app/pachli/MainActivity.kt @@ -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 { diff --git a/app/src/main/java/app/pachli/usecase/LogoutUsecase.kt b/app/src/main/java/app/pachli/usecase/LogoutUseCase.kt similarity index 96% rename from app/src/main/java/app/pachli/usecase/LogoutUsecase.kt rename to app/src/main/java/app/pachli/usecase/LogoutUseCase.kt index 165e50a05..6c56a9e42 100644 --- a/app/src/main/java/app/pachli/usecase/LogoutUsecase.kt +++ b/app/src/main/java/app/pachli/usecase/LogoutUseCase.kt @@ -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