Refactor: Remove all `v` delegate variables

This commit is contained in:
Svallinn 2021-05-22 00:52:11 +01:00
parent 4686d21bd3
commit e72fbcf0a4
No known key found for this signature in database
GPG Key ID: 09FB527F34037CCA
2 changed files with 27 additions and 36 deletions

View File

@ -82,7 +82,6 @@ export default Vue.extend({
} }
}, },
mounted: function () { mounted: function () {
const v = this
this.$store.dispatch('grabUserSettings').then(() => { this.$store.dispatch('grabUserSettings').then(() => {
this.$store.dispatch('grabAllProfiles', this.$t('Profile.All Channels')).then(async () => { this.$store.dispatch('grabAllProfiles', this.$t('Profile.All Channels')).then(async () => {
this.$store.dispatch('grabHistory') this.$store.dispatch('grabHistory')
@ -91,7 +90,7 @@ export default Vue.extend({
this.checkThemeSettings() this.checkThemeSettings()
await this.checkLocale() await this.checkLocale()
v.dataReady = true this.dataReady = true
if (useElectron) { if (useElectron) {
console.log('User is using Electron') console.log('User is using Electron')
@ -377,10 +376,9 @@ export default Vue.extend({
}, },
enableOpenUrl: function () { enableOpenUrl: function () {
const v = this ipcRenderer.on('openUrl', (event, url) => {
ipcRenderer.on('openUrl', function (event, url) {
if (url) { if (url) {
v.handleYoutubeLink(url) this.handleYoutubeLink(url)
} }
}) })

View File

@ -256,22 +256,20 @@ export default Vue.extend({
this.player.on('fullscreenchange', this.fullscreenOverlay) this.player.on('fullscreenchange', this.fullscreenOverlay)
this.player.on('fullscreenchange', this.toggleFullscreenClass) this.player.on('fullscreenchange', this.toggleFullscreenClass)
const v = this this.player.on('ready', () => {
this.$emit('ready')
this.player.on('ready', function () { this.checkAspectRatio()
v.$emit('ready') if (this.captionHybridList.length !== 0) {
v.checkAspectRatio() this.transformAndInsertCaptions()
if (v.captionHybridList.length !== 0) {
v.transformAndInsertCaptions()
} }
}) })
this.player.on('ended', function () { this.player.on('ended', () => {
v.$emit('ended') this.$emit('ended')
}) })
this.player.on('error', function (error, message) { this.player.on('error', (error, message) => {
v.$emit('error', error.target.player.error_) this.$emit('error', error.target.player.error_)
}) })
this.player.on('play', async function () { this.player.on('play', async function () {
@ -866,14 +864,13 @@ export default Vue.extend({
}, },
createLoopButton: function () { createLoopButton: function () {
const v = this
const VjsButton = videojs.getComponent('Button') const VjsButton = videojs.getComponent('Button')
const loopButton = videojs.extend(VjsButton, { const loopButton = videojs.extend(VjsButton, {
constructor: function(player, options) { constructor: function(player, options) {
VjsButton.call(this, player, options) VjsButton.call(this, player, options)
}, },
handleClick: function() { handleClick: () => {
v.toggleVideoLoop() this.toggleVideoLoop()
}, },
createControlTextEl: function (button) { createControlTextEl: function (button) {
return $(button).html($('<div id="loopButton" class="vjs-icon-loop loop-white vjs-button loopWhite"></div>') return $(button).html($('<div id="loopButton" class="vjs-icon-loop loop-white vjs-button loopWhite"></div>')
@ -912,14 +909,13 @@ export default Vue.extend({
}, },
createFullWindowButton: function () { createFullWindowButton: function () {
const v = this
const VjsButton = videojs.getComponent('Button') const VjsButton = videojs.getComponent('Button')
const fullWindowButton = videojs.extend(VjsButton, { const fullWindowButton = videojs.extend(VjsButton, {
constructor: function(player, options) { constructor: function(player, options) {
VjsButton.call(this, player, options) VjsButton.call(this, player, options)
}, },
handleClick: function() { handleClick: () => {
v.toggleFullWindow() this.toggleFullWindow()
}, },
createControlTextEl: function (button) { createControlTextEl: function (button) {
// Add class name to button to be able to target it with CSS selector // Add class name to button to be able to target it with CSS selector
@ -933,7 +929,6 @@ export default Vue.extend({
}, },
createDashQualitySelector: function (levels) { createDashQualitySelector: function (levels) {
const v = this
if (levels.levels_.length === 0) { if (levels.levels_.length === 0) {
setTimeout(() => { setTimeout(() => {
this.createDashQualitySelector(this.player.qualityLevels()) this.createDashQualitySelector(this.player.qualityLevels())
@ -945,13 +940,13 @@ export default Vue.extend({
constructor: function(player, options) { constructor: function(player, options) {
VjsButton.call(this, player, options) VjsButton.call(this, player, options)
}, },
handleClick: function(event) { handleClick: (event) => {
console.log(event) console.log(event)
const selectedQuality = event.target.innerText const selectedQuality = event.target.innerText
const bitrate = selectedQuality === 'auto' ? 'auto' : parseInt(event.target.attributes.bitrate.value) const bitrate = selectedQuality === 'auto' ? 'auto' : parseInt(event.target.attributes.bitrate.value)
v.setDashQualityLevel(bitrate) this.setDashQualityLevel(bitrate)
}, },
createControlTextEl: function (button) { createControlTextEl: (button) => {
const beginningHtml = `<div class="vjs-quality-level-value"> const beginningHtml = `<div class="vjs-quality-level-value">
<span id="vjs-current-quality">1080p</span> <span id="vjs-current-quality">1080p</span>
</div> </div>
@ -975,12 +970,12 @@ export default Vue.extend({
let qualityLabel let qualityLabel
let bitrate let bitrate
if (typeof v.adaptiveFormats !== 'undefined' && v.adaptiveFormats.length > 0) { if (typeof this.adaptiveFormats !== 'undefined' && this.adaptiveFormats.length > 0) {
const adaptiveFormat = v.adaptiveFormats.find((format) => { const adaptiveFormat = this.adaptiveFormats.find((format) => {
return format.bitrate === quality.bitrate return format.bitrate === quality.bitrate
}) })
v.activeAdaptiveFormats.push(adaptiveFormat) this.activeAdaptiveFormats.push(adaptiveFormat)
fps = adaptiveFormat.fps fps = adaptiveFormat.fps
qualityLabel = adaptiveFormat.qualityLabel ? adaptiveFormat.qualityLabel : quality.height + 'p' qualityLabel = adaptiveFormat.qualityLabel ? adaptiveFormat.qualityLabel : quality.height + 'p'
@ -1104,12 +1099,11 @@ export default Vue.extend({
}, },
fullscreenOverlay: function () { fullscreenOverlay: function () {
const v = this
const title = document.title.replace('- FreeTube', '') const title = document.title.replace('- FreeTube', '')
if (this.player.isFullscreen()) { if (this.player.isFullscreen()) {
this.player.ready(function () { this.player.ready(() => {
v.player.overlay({ this.player.overlay({
overlays: [{ overlays: [{
showBackground: false, showBackground: false,
content: title, content: title,
@ -1119,8 +1113,8 @@ export default Vue.extend({
}) })
}) })
} else { } else {
this.player.ready(function () { this.player.ready(() => {
v.player.overlay({ this.player.overlay({
overlays: [{ overlays: [{
showBackground: false, showBackground: false,
content: ' ', content: ' ',
@ -1141,9 +1135,8 @@ export default Vue.extend({
}, },
handleTouchStart: function (event) { handleTouchStart: function (event) {
const v = this
this.touchPauseTimeout = setTimeout(() => { this.touchPauseTimeout = setTimeout(() => {
v.togglePlayPause() this.togglePlayPause()
}, 1000) }, 1000)
const touchTime = new Date() const touchTime = new Date()