This commit is contained in:
Jobobby04 2021-07-25 14:15:27 -04:00
parent 1699c2ed67
commit 81af5a5654
2 changed files with 12 additions and 23 deletions

View File

@ -44,7 +44,6 @@ import exh.md.utils.MdUtil
import exh.metadata.metadata.MangaDexSearchMetadata
import exh.source.DelegatedHttpSource
import exh.ui.metadata.adapters.MangaDexDescriptionAdapter
import kotlinx.coroutines.CancellationException
import okhttp3.OkHttpClient
import okhttp3.Response
import rx.Observable

View File

@ -10,19 +10,17 @@ import eu.kanade.tachiyomi.source.Source
import eu.kanade.tachiyomi.source.SourceManager
import eu.kanade.tachiyomi.source.online.LoginSource
import eu.kanade.tachiyomi.ui.base.controller.DialogController
import eu.kanade.tachiyomi.util.lang.launchNow
import eu.kanade.tachiyomi.util.lang.withIOContext
import eu.kanade.tachiyomi.util.lang.launchIO
import eu.kanade.tachiyomi.util.lang.withUIContext
import eu.kanade.tachiyomi.util.system.toast
import exh.source.getMainSource
import kotlinx.coroutines.supervisorScope
import uy.kohesive.injekt.Injekt
import uy.kohesive.injekt.api.get
import uy.kohesive.injekt.injectLazy
class MangadexLogoutDialog(bundle: Bundle? = null) : DialogController(bundle) {
val source = Injekt.get<SourceManager>().get(args.getLong("key", 0))?.getMainSource() as? LoginSource
val source = Injekt.get<SourceManager>().get(args.getLong("key", 0))?.getMainSource() as LoginSource
val trackManager: TrackManager by injectLazy()
@ -36,14 +34,8 @@ class MangadexLogoutDialog(bundle: Bundle? = null) : DialogController(bundle) {
return MaterialAlertDialogBuilder(activity!!)
.setTitle(R.string.logout)
.setPositiveButton(R.string.logout) { _, _ ->
launchNow {
supervisorScope {
if (source != null) {
val loggedOut = withIOContext {
source.logout()
}
if (loggedOut) {
launchIO {
if (source.logout()) {
withUIContext {
activity?.toast(R.string.logout_success)
}
@ -53,8 +45,6 @@ class MangadexLogoutDialog(bundle: Bundle? = null) : DialogController(bundle) {
activity?.toast(R.string.unknown_error)
}
}
} else withUIContext { activity?.toast("Mangadex not enabled") }
}
}
}
.setNegativeButton(android.R.string.cancel, null)