From e72fbcf0a4ed6a17843e783236f300874b95e88a Mon Sep 17 00:00:00 2001 From: Svallinn <41585298+Svallinn@users.noreply.github.com> Date: Sat, 22 May 2021 00:52:11 +0100 Subject: [PATCH] Refactor: Remove all `v` delegate variables --- src/renderer/App.js | 8 +-- .../ft-video-player/ft-video-player.js | 55 ++++++++----------- 2 files changed, 27 insertions(+), 36 deletions(-) diff --git a/src/renderer/App.js b/src/renderer/App.js index 6be3fca7..4ae67086 100644 --- a/src/renderer/App.js +++ b/src/renderer/App.js @@ -82,7 +82,6 @@ export default Vue.extend({ } }, mounted: function () { - const v = this this.$store.dispatch('grabUserSettings').then(() => { this.$store.dispatch('grabAllProfiles', this.$t('Profile.All Channels')).then(async () => { this.$store.dispatch('grabHistory') @@ -91,7 +90,7 @@ export default Vue.extend({ this.checkThemeSettings() await this.checkLocale() - v.dataReady = true + this.dataReady = true if (useElectron) { console.log('User is using Electron') @@ -377,10 +376,9 @@ export default Vue.extend({ }, enableOpenUrl: function () { - const v = this - ipcRenderer.on('openUrl', function (event, url) { + ipcRenderer.on('openUrl', (event, url) => { if (url) { - v.handleYoutubeLink(url) + this.handleYoutubeLink(url) } }) diff --git a/src/renderer/components/ft-video-player/ft-video-player.js b/src/renderer/components/ft-video-player/ft-video-player.js index 54b099c9..421b9fdf 100644 --- a/src/renderer/components/ft-video-player/ft-video-player.js +++ b/src/renderer/components/ft-video-player/ft-video-player.js @@ -256,22 +256,20 @@ export default Vue.extend({ this.player.on('fullscreenchange', this.fullscreenOverlay) this.player.on('fullscreenchange', this.toggleFullscreenClass) - const v = this - - this.player.on('ready', function () { - v.$emit('ready') - v.checkAspectRatio() - if (v.captionHybridList.length !== 0) { - v.transformAndInsertCaptions() + this.player.on('ready', () => { + this.$emit('ready') + this.checkAspectRatio() + if (this.captionHybridList.length !== 0) { + this.transformAndInsertCaptions() } }) - this.player.on('ended', function () { - v.$emit('ended') + this.player.on('ended', () => { + this.$emit('ended') }) - this.player.on('error', function (error, message) { - v.$emit('error', error.target.player.error_) + this.player.on('error', (error, message) => { + this.$emit('error', error.target.player.error_) }) this.player.on('play', async function () { @@ -866,14 +864,13 @@ export default Vue.extend({ }, createLoopButton: function () { - const v = this const VjsButton = videojs.getComponent('Button') const loopButton = videojs.extend(VjsButton, { constructor: function(player, options) { VjsButton.call(this, player, options) }, - handleClick: function() { - v.toggleVideoLoop() + handleClick: () => { + this.toggleVideoLoop() }, createControlTextEl: function (button) { return $(button).html($('
') @@ -912,14 +909,13 @@ export default Vue.extend({ }, createFullWindowButton: function () { - const v = this const VjsButton = videojs.getComponent('Button') const fullWindowButton = videojs.extend(VjsButton, { constructor: function(player, options) { VjsButton.call(this, player, options) }, - handleClick: function() { - v.toggleFullWindow() + handleClick: () => { + this.toggleFullWindow() }, createControlTextEl: function (button) { // 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) { - const v = this if (levels.levels_.length === 0) { setTimeout(() => { this.createDashQualitySelector(this.player.qualityLevels()) @@ -945,13 +940,13 @@ export default Vue.extend({ constructor: function(player, options) { VjsButton.call(this, player, options) }, - handleClick: function(event) { + handleClick: (event) => { console.log(event) const selectedQuality = event.target.innerText const bitrate = selectedQuality === 'auto' ? 'auto' : parseInt(event.target.attributes.bitrate.value) - v.setDashQualityLevel(bitrate) + this.setDashQualityLevel(bitrate) }, - createControlTextEl: function (button) { + createControlTextEl: (button) => { const beginningHtml = `