-
Notifications
You must be signed in to change notification settings - Fork 4
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
base: master
Are you sure you want to change the base?
Conversation
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.
Codecov ReportAttention: Patch coverage is
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
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
Passing run #11281 ↗︎
Details:
Review all test suite changes for PR #2204 ↗︎ |
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.
I don't think this will work as written -- see details below.
const imageEntry = gImageMap.getCachedImage(value); | ||
if (!imageEntry) { |
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.
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));
}
});
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.