-
Notifications
You must be signed in to change notification settings - Fork 1
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
JIDEA-183: Use page route to determine whether globe component is loaded #90
JIDEA-183: Use page route to determine whether globe component is loaded #90
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #90 +/- ##
==========================================
- Coverage 1.62% 1.39% -0.24%
==========================================
Files 54 54
Lines 146163 146175 +12
Branches 306 310 +4
==========================================
- Hits 2379 2035 -344
- Misses 143768 144123 +355
- Partials 16 17 +1 ☔ View full report in Codecov by Sentry. |
|
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.
Thanks for the copious comments - this is a bit twisty so they're very useful!
layouts/default.vue
Outdated
if (!loadGlobeComponent.value) { | ||
// Set the loadGlobeComponent value here, rather than using a computed property, since the app store initializes with the assumption | ||
// that largeScreen is true, and so using a computed would mean that we always try to load the globe on the initial page load. | ||
loadGlobeComponent.value = appStore.largeScreen && pagesUsingGlobe.includes(route.name as string); |
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.
Could you do this here?
loadGlobeComponent.value = appStore.largeScreen && pagesUsingGlobe.includes(route.name as string); | |
loadGlobeComponent.value = showGlobe.value; |
largeScreen should be set correctly at the point where you check its value here.
Also, this isn't checking globeParameter as showGlobe
is, but feels like that's relevant for loading too..
watch(() => route.name, () => { | ||
setGlobeComponent(); | ||
}); | ||
|
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 didn't expect this pick up the case where you start off with a small window (but on a large screen) which you then expand, so globe should load. But it did! 😕 Does it do a reload when the window size changes?
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.
Well, if I put in a console.log
into this watch, it only fires when I change the route, and correctly not when I change the screen size. What is the confusion?
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 you start off with a small window/screen, you don't want it to load the globe initially... but then you do want it to load if you expand the window size. Which it does! But I'm not sure how it's doing that when it's not watching for changes to the screen size which would setGlobeComponent
to set the loadGlobeComponent
value.
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.
onMounted has window.addEventListener("resize", setScreenSize);
setScreenSize runs setGlobeComponent();
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.
and setGlobeComponent sets loadGlobeComponent.value
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.
Sorry, yes, I managed to completely fail to see that line! 👓
Context: https://mrc-ide.myjetbrains.com/youtrack/issue/JIDEA-183/Make-chart-work-with-v-if
In this PR we (continue to) use Nuxt's 'dynamic imports' feature (hence
LazyGlobe
, which loads lazily) to determine when to load the Globe component. Till now, it was loading on the About page (as long as largeScreen was true) unnecessarily.