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 delete()
fun delete(): Try<Unit>
}

View File

@ -50,14 +50,16 @@ internal class RealmSessionParamsStore(private val mapper: SessionParamsMapper,
return sessionParams
}
override fun delete() {
val realm = Realm.getInstance(realmConfiguration)
realm.executeTransaction {
it.where(SessionParamsEntity::class.java)
.findAll()
.deleteAllFromRealm()
override fun delete(): Try<Unit> {
return Try {
val realm = Realm.getInstance(realmConfiguration)
realm.executeTransaction {
it.where(SessionParamsEntity::class.java)
.findAll()
.deleteAllFromRealm()
}
realm.close()
}
realm.close()
}
}

View File

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