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:
William Brawner 2022-11-11 21:22:21 -07:00
parent 365026e1a0
commit e84dc04418

View file

@ -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 {