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
fix: workaround for pollAttempt fail in courseview #142
fix: workaround for pollAttempt fail in courseview #142
Changes from 3 commits
dacc6e6
1ca8517
be138b5
47bb4a7
620f89b
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
Why are these comments in the PR?
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.
Ah I left those in by accident, let me remove those real quick
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.
My understanding of
timerEnds
is that it should have a consistent value across calls topollAttempt
. Its purpose is to be a fixed time reference. What are the values oftimerEnds
that you're seeing locally that are not equal? I'd like for you or Marcos to double-check me on my understanding, though!Unfortunately, written as is, this
useEffect
hook needs to havetimerEnds
in the dependency array, because it's used within the hook; see Specifying Reactive dependencies. If we were to movedeadline
outside of the hook, we could removetimerEnds
from the dependency array. I think that should be fine, assumingtimerEnds
represents a static time.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.
Yes, I've mentioned this on our slack thread. This was an oversight from me when I worked on the
TimerProvider
. Removing the dependency is not the best approach.I think the best would be to move this dependency to a reference so it does not need to be added as a dependency and if it gets updated it will not re-run the
useEffect
. We should just make sure that we are always using the reference instead of the primitive to avoid any issues.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.
To reply the question above:
The problem here is caused by
timerEnds
being recalculated in each poll. Since the endpoint returns only the remaining seconds, this value can mean different things depending the time is evaluated. In this case, sincetimerEnds
gets calculated when is saved at the store, this value probably gets a slightly minor offset every time (depending on network and execution delay), so the value is slightly different and the hook reacts to it.This was the original problem for ticket COSMO-180 since every render it would take the remaining seconds again from the store based on the poll time and not the current time.
Is there a possibility to update the endpoint to return a datetime instead of the remaining seconds? Although this would mean that we need to deal with time offsets...
This problem could use some brainstorming.
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.
Marcos paired with me and we were able to fix this :)