Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
Moving loader to logo in header, add a slight 250ms pause #78879
Moving loader to logo in header, add a slight 250ms pause #78879
Changes from 5 commits
79a001c
31ffea1
d87f175
744bbb3
da57992
75fd6d8
c25bf1f
98477ed
0339431
26b95c5
5c4c09a
1e81d25
b5e7995
50db7c6
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Large diffs are not rendered by default.
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.
optional: It could be a source of flakiness on CI. We might implement a function polling the element presence (as in FTR TestSubjects.exists or remove the time factor in tests https://jestjs.io/docs/en/timer-mocks#run-all-timers
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.
NIT:
private timer?: number;
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 is a number. It relates to the setTimeout function. TS complains.
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.
timeout ids are numbers
What does TS complains about exactly?
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.
As
increment
is initialized to1
, I'm ensure to understand what exactly this block does. Both theif (this.increment > 1)
(that would be alwaystrue
) andthis.increment += this.increment;
seems wrong to me?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.
It makes sure that the 250 pause only starts the first time the cycle begins. You can see that it does print initially and only increases when the subscription does.
The subscription code isn't the most approachable, but this method seemed to do what was needed: only show a loading indicator if a new "loading event" existed for more than 250ms.
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.
So, the delay is reset every time
loadingCount
emits a new value, meaning that if there are consecutive requests firing at an interval <250
, the loader will never be displayed until 250ms after the last one. Is that the expected behavior?Shouldn't we start the timer the first time
loadingCount$
is greater than 0, but not on the next emissions untilloadingCount
is back to0
?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'll be honest, if you have experience with this code, feel free to commit on top of it. The way the subscription numbers shifted felt weird.
In any case the problem I was trying to solve from a UI perspective with the current functionality:
The loading action "blips" for minor events. Basically, ANY time the subscription changed (which is often) it would signal. Less than a second of loading, and the user won't even notice the load, but they would notice an annoying animation on the page. We'd prefer not to show it in those cases, and only show it for sustained loads. I think what your'e saying is the correct way to handle it. Look for it to go back to zero, then start the count, and see if the number is larger than zero.
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.
+1 to Pierre's comments
I can add this to my queue if you're not sure how to implement it but I don't think I'll get to it for at least a few days (if someone else has time before me, feel free to jump in)
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'm gonna give this a shot tonight. I'll bug you all tomorrow for a review.