-
Notifications
You must be signed in to change notification settings - Fork 291
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: use local users if they cannot be loaded from BE [WPB-5959] #16405
Conversation
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## dev #16405 +/- ##
==========================================
+ Coverage 45.48% 45.49% +0.01%
==========================================
Files 736 734 -2
Lines 23972 23945 -27
Branches 5454 5442 -12
==========================================
- Hits 10903 10894 -9
+ Misses 11669 11656 -13
+ Partials 1400 1395 -5 |
4e789df
to
d6ecc63
Compare
const dbUserRecord = dbUsers?.find(user => matchQualifiedIds(user.qualified_id, userId)); | ||
|
||
if (dbUserRecord && selfUser) { | ||
return this.userMapper.mapUserFromJson(dbUserRecord, selfDomain); | ||
} | ||
|
||
// Otherwise, we generate placeholder users locally with some default values. | ||
return new User(userId.id, userId.domain); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Before returning a placeholder for "unavailable user" we try looking it up in local indexedDB because there's a chance that we've already saved this user before.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ohhh that's a pretty nice solution 😎 🚀
nice job man
Description
When initially loading a list of users, it can happen that one of the federated backends is offline (unreachable), therefore we will not receive fresh user data from the server. It's possible that we've already fetched this user before, thus we can try looking it up in local db (indexedDB) before just returning a placeholder for "unavailable user".
Checklist