Improve signout task

This commit is contained in:
Benoit Marty 2019-04-04 11:10:45 +02:00
parent 82d89825d3
commit 43659dffd3
3 changed files with 11 additions and 9 deletions

View File

@ -25,5 +25,5 @@ internal interface SessionParamsStore {


fun save(sessionParams: SessionParams): Try<SessionParams> fun save(sessionParams: SessionParams): Try<SessionParams>


fun delete() fun delete(): Try<Unit>
} }

View File

@ -50,7 +50,8 @@ internal class RealmSessionParamsStore(private val mapper: SessionParamsMapper,
return sessionParams return sessionParams
} }


override fun delete() { override fun delete(): Try<Unit> {
return Try {
val realm = Realm.getInstance(realmConfiguration) val realm = Realm.getInstance(realmConfiguration)
realm.executeTransaction { realm.executeTransaction {
it.where(SessionParamsEntity::class.java) it.where(SessionParamsEntity::class.java)
@ -59,5 +60,6 @@ internal class RealmSessionParamsStore(private val mapper: SessionParamsMapper,
} }
realm.close() realm.close()
} }
}


} }

View File

@ -30,7 +30,7 @@ internal class DefaultSignOutTask(private val signOutAPI: SignOutAPI,
override fun execute(params: Unit): Try<Unit> { override fun execute(params: Unit): Try<Unit> {
return executeRequest<Unit> { return executeRequest<Unit> {
apiCall = signOutAPI.signOut() apiCall = signOutAPI.signOut()
}.map { }.flatMap {
// TODO Clear DB, media cache, etc. // TODO Clear DB, media cache, etc.
sessionParamsStore.delete() sessionParamsStore.delete()
} }