Always fetch the latest user object
Previously the user wasn't fetched if it was already cached, so we may have been missing updates
This commit is contained in:
parent
365026e1a0
commit
e84dc04418
1 changed files with 12 additions and 1 deletions
|
@ -90,7 +90,18 @@ class UserRepository @Inject constructor(
|
|||
if (it == -1L) {
|
||||
null
|
||||
} else {
|
||||
userDao.getAllByIds(it).firstOrNull()
|
||||
userDao.getAllByIds(it)
|
||||
.firstOrNull()
|
||||
?.apply {
|
||||
try {
|
||||
apiService.getCurrentUser().also { user ->
|
||||
userDao.insertAll(user)
|
||||
_currentUser.emit(user)
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
logger.e(e)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
?: apiService.getCurrentUser().also {
|
||||
|
|
Loading…
Reference in a new issue