vjs: hide errors when updating i18n

## Issue
6989 console errors and warnings are getting out of hand!

## Notes
This method was previously criticized in 5643. But given that no better solution has been submitted after a long while, nor is there a new solution for doing i18n, I'm reviving it again. It'll be no worse from the status quo.

Despite try-catch being overkill, I think the code-clarity outweighs the performance issues (if any, in the first place). Also, we are only suppressing the error in a very specialized function which even if it fails, will simply be a no-op and the GUI falling back to English.
This commit is contained in:
infinite-persistence 2021-09-02 16:04:23 +08:00
parent 72cceac943
commit 18fb0147de
No known key found for this signature in database
GPG key ID: B9C3252EDC3D0AA0

View file

@ -296,6 +296,7 @@ export default React.memo<Props>(function VideoJs(props: Props) {
// as the listener to update static texts. // as the listener to update static texts.
const player = playerRef.current; const player = playerRef.current;
if (player) { if (player) {
try {
const controlBar = player.getChild('controlBar'); const controlBar = player.getChild('controlBar');
switch (e.type) { switch (e.type) {
case 'play': case 'play':
@ -335,6 +336,10 @@ export default React.memo<Props>(function VideoJs(props: Props) {
if (isDev) throw Error('Unexpected: ' + e.type); if (isDev) throw Error('Unexpected: ' + e.type);
break; break;
} }
} catch {
// Just fail silently. It'll just be due to hidden ctrls, and if it is
// due to control hierarchy change, we'll notice that in the GUI.
}
} }
} }