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

use the existing image map cache #2204

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

scytacki
Copy link
Member

Rather than maintaining a second cache of promises, use the existing cache.

Even better than this would be to use the observability of the ImageMapEntry objects. However I'm not sure how easy it would be to make the column formatter work as an observable component.

Rather than maintaining a second cache of promises, use the existing cache.

Even better than this would be to use the observability of the ImageMapEntry objects. However I'm not sure how easy it would be to make the column `formatter` work as an observable component.
Copy link

codecov bot commented Feb 25, 2024

Codecov Report

Attention: Patch coverage is 25.00000% with 3 lines in your changes are missing coverage. Please review.

Project coverage is 83.37%. Comparing base (d050613) to head (cabc444).
Report is 2 commits behind head on master.

Files Patch % Lines
src/components/tiles/table/table-tile.tsx 25.00% 2 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2204      +/-   ##
==========================================
- Coverage   83.37%   83.37%   -0.01%     
==========================================
  Files         686      686              
  Lines       34094    34091       -3     
  Branches     8845     8845              
==========================================
- Hits        28426    28423       -3     
  Misses       5370     5370              
  Partials      298      298              
Flag Coverage Δ
cypress ?
cypress-regression 73.05% <0.00%> (+0.04%) ⬆️
cypress-smoke 30.08% <0.00%> (-0.01%) ⬇️
jest 51.82% <25.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

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

Copy link

cypress bot commented Feb 25, 2024

Passing run #11281 ↗︎

0 91 5 0 Flakiness 0

Details:

use the existing image map cache
Project: collaborative-learning Commit: cabc444ba7
Status: Passed Duration: 11:53 💡
Started: Feb 27, 2024 2:04 PM Ended: Feb 27, 2024 2:16 PM

Review all test suite changes for PR #2204 ↗︎

@scytacki scytacki marked this pull request as ready for review February 27, 2024 16:07
Copy link
Member

@kswenson kswenson left a comment

Choose a reason for hiding this comment

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

I don't think this will work as written -- see details below.

Comment on lines +97 to +98
const imageEntry = gImageMap.getCachedImage(value);
if (!imageEntry) {
Copy link
Member

Choose a reason for hiding this comment

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

If the image had already been cached (e.g. because it's used elsewhere in the document) when we get here, then it will never be loaded. You could add an else clause but then you're potentially back to the infinite loop situation. It seems to me you still need some kind of local state to keep track of which image urls have been considered locally.

Maybe you could simplify it to something like this:

        gImageMap.getImage(value).then((image) => {
          if (image?.displayUrl && imageUrls.get(value) !== image?.displayUrl) {
            // This state changes triggers a re-render
            setImageUrls(urls => new Map(urls).set(value, image.displayUrl));
          }
        });

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.

2 participants