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

Uppy refresh token logic #1152

Draft
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

joshuadkitenge
Copy link
Collaborator

Description

  • Fix existing code so it use relevant api client instead of imsApi
  • refactor thumbnail view logic to use displayed images
  • remove upload error uppy event listener as it not needed as backend deals with image errors
  • create uppy uppyOnBeforeRequest function that set the auth headers
  • create uppyOnAfterResponse to deal with 403 errors

Testing instructions

  • Review code
  • Check Actions build
  • Review changes to test coverage

Agile board tracking

closes #1147

- Fix existing code so it use relevant api client instead of imsApi
- refactor thumbnail view logic to use displayed images
- remove upload error uppy event listener as it not needed as backend
  deals with image errors
- create uppy uppyOnBeforeRequest function that set the auth headers
- create uppyOnAfterResponse to deal with 403 errors
Comment on lines +132 to +137
const timeoutId = setTimeout(() => {
// If the token isn't refreshed within a reasonable timeframe, reject the promise
document.removeEventListener(MicroFrontendId, handler);
isFetchingAccessToken = false;
reject();
}, 20 * 1000); // 20 seconds timeout
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a reject case to handle scenarios where the expected CustomEvent does not occur or takes too long.
Ensures the Promise does not hang indefinitely

Copy link

codecov bot commented Dec 11, 2024

Codecov Report

Attention: Patch coverage is 33.89831% with 39 lines in your changes missing coverage. Please review.

Project coverage is 99.03%. Comparing base (b72d8e1) to head (6d453b8).
Report is 1 commits behind head on develop.

Files with missing lines Patch % Lines
src/api/api.tsx 15.21% 39 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #1152      +/-   ##
===========================================
- Coverage    99.23%   99.03%   -0.21%     
===========================================
  Files           88       88              
  Lines        17876    17920      +44     
  Branches      2946     2947       +1     
===========================================
+ Hits         17740    17747       +7     
- Misses         135      169      +34     
- Partials         1        4       +3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Use API refresh logic on image upload
1 participant