Skip to content
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

Merged
merged 2 commits into from
Dec 21, 2023

Conversation

PatrykBuniX
Copy link
Contributor

@PatrykBuniX PatrykBuniX commented Dec 20, 2023

BugWPB-5959 [Web] 1:1 MLS conversation disappears after page refresh when of user's backend goes offline

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

  • PR has been self reviewed by the author;
  • Hard-to-understand areas of the code have been commented;
  • If it is a core feature, unit tests have been added;

Copy link

codecov bot commented Dec 20, 2023

Codecov Report

Attention: 6 lines in your changes are missing coverage. Please review.

Comparison is base (e820de8) 45.48% compared to head (ffe523b) 45.49%.
Report is 15 commits behind head on dev.

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     

@PatrykBuniX PatrykBuniX force-pushed the runfix/dont-filter-orphan-users branch from 4e789df to d6ecc63 Compare December 21, 2023 12:18
@PatrykBuniX PatrykBuniX changed the title fix: don't filter out orphan users on initial users load [WPB-5959] fix: use local users if they cannot be loaded from BE [WPB-5959] Dec 21, 2023
@PatrykBuniX PatrykBuniX marked this pull request as ready for review December 21, 2023 12:23
@PatrykBuniX PatrykBuniX requested review from otto-the-bot and a team as code owners December 21, 2023 12:23
Comment on lines +606 to +613
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);
Copy link
Contributor Author

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.

Copy link
Contributor

@atomrc atomrc left a 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

@PatrykBuniX PatrykBuniX merged commit 40224c4 into dev Dec 21, 2023
8 checks passed
@PatrykBuniX PatrykBuniX deleted the runfix/dont-filter-orphan-users branch December 21, 2023 12:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants