-
Notifications
You must be signed in to change notification settings - Fork 54
Add AV embed timeout handling to Media Player #2836
Conversation
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.
This is coming together nicely, however I was originally of the thought that we would reuse the psammead-embed-error
component for this.
Thanks, Rowland. You raise a good point. The reason I went down this route is because:
|
Thanks for the concise explanation Simon. I think with regards to #2544, we might have to decouple the timeout logic somehow but I believe this is not a priority right now. 👍 |
Thanks for figuring out a solution to this Simon. Although like Rowland I had assumed we would reuse the existing error component just to limit the number of components we have to think about. My main other observation is that useTimeout.jsx would really benefit from some explanatory comments, but good otherwise. |
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 sorting the wording @simonsinclair looks great :)
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.
Looks great, few small queries but it's good to go as far as I'm concerned.
The `mediaInfo` prop is required, and has the following properties. | ||
The `timeoutMs` prop allows you to override the default timeout value. If media fails to load in this time, users are shown a timeout message. |
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.
Might be good to document that this only applies to canonical and not AMP?
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's not immediately obvious from the files changed diff on GitHub, but the readme is split into Canonical and AMP sections and this prop is only listed beneath Canonical.
* completes, and `false` if it's interrupted. | ||
* @param {object} iframeRef A React Ref. providing access to an iframe DOM node. | ||
* @param {number} timeout The number of milliseconds until the timer completes. | ||
*/ |
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.
Comments in this file are excellent.
// eslint-disable-next-line consistent-return | ||
useEffect(() => { | ||
if (timeout > 0) { | ||
iframeRef.current.addEventListener('load', handleLoad, { once: true }); |
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.
The value of .current
is guaranteed to be defined at this point, right?
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 iframeRef
is created as documented (as a React Ref), it will be, but perhaps this should be more defensively written. I deliberated over this for a while and appreciate you raising it. It should probably throw if current
is falsy. I'll make this change now.
Co-Authored-By: James Donohue <james.donohue@bbc.co.uk>
…into media-player-timeout
Looks good to me.. |
Resolves bbc/simorgh#4517.
Overall change: Handle AV embed timeouts gracefully by displaying an error message to users.
Code changes:
Note: