-
Notifications
You must be signed in to change notification settings - Fork 26
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
perf: lazy validators (ME-15925) #606
Changes from 1 commit
eb6d654
0760c5e
f8a11a4
23ad3d9
d435ca5
6e9e1a8
87c3b9f
e947215
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,8 +18,7 @@ import { | |
overrideDefaultVideojsComponents | ||
} from './video-player.utils'; | ||
import { FLOATING_TO, FLUID_CLASS_NAME } from './video-player.const'; | ||
import { isValidConfig } from './validators/validators-functions'; | ||
import { playerValidators, sourceValidators } from './validators/validators'; | ||
import { isValidPlayerConfig, isValidSourceConfig } from './validators/validators-functions'; | ||
import { PLAYER_EVENT, SOURCE_TYPE } from './utils/consts'; | ||
import { getAnalyticsFromPlayerOptions } from './utils/get-analytics-player-options'; | ||
import { extendCloudinaryConfig, normalizeOptions, isRawUrl } from './plugins/cloudinary/common'; | ||
|
@@ -72,14 +71,15 @@ class VideoPlayer extends Utils.mixin(Eventable) { | |
|
||
this.videojs = videojs(this.videoElement, this._videojsOptions); | ||
|
||
// to do, should be change by isValidConfig | ||
this._isPlayerConfigValid = true; | ||
|
||
isValidConfig(this.options, playerValidators); | ||
|
||
if (!this._isPlayerConfigValid) { | ||
this.videojs.error('invalid player configuration'); | ||
return; | ||
if (this.playerOptions.debug) { | ||
isValidPlayerConfig(this.options).then((valid) => { | ||
if (!valid) { | ||
this._isPlayerConfigValid = valid; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why not set it directly to false? |
||
this.videojs.error('invalid player configuration'); | ||
return; | ||
} | ||
}); | ||
} | ||
|
||
if (this._videojsOptions.muted) { | ||
|
@@ -390,7 +390,7 @@ class VideoPlayer extends Utils.mixin(Eventable) { | |
_initAnalytics() { | ||
const analyticsOpts = this.playerOptions.analytics; | ||
|
||
if (!window.ga && analyticsOpts) { | ||
if (!window.ga && analyticsOpts && this.playerOptions.debug) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For later i think it is better to create an abstract that wraps the console.error statement and considers the debug mode. |
||
console.error('Google Analytics script is missing'); | ||
return; | ||
} | ||
|
@@ -528,11 +528,12 @@ class VideoPlayer extends Utils.mixin(Eventable) { | |
return; | ||
} | ||
|
||
const isSourceConfigValid = isValidConfig(options, sourceValidators); | ||
|
||
if (!isSourceConfigValid) { | ||
this.videojs.error('invalid source configuration'); | ||
return; | ||
if (this.playerOptions.debug) { | ||
isValidSourceConfig(options).then((valid) => { | ||
if (!valid) { | ||
this.videojs.error('invalid source configuration'); | ||
} | ||
}); | ||
} | ||
|
||
this._sendInternalAnalytics({ source: options }); | ||
|
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.
Suppress a deprecation console warning regarding
videojs.bind
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.
@tsi is it riksy? because our assumption was that this PR would be focusing on very minimal risk stuff.
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 so, but let's wait with it till next release