From f2d2827e0f08679ee2297d9df605feba02ad101e Mon Sep 17 00:00:00 2001 From: absidue <48293849+absidue@users.noreply.github.com> Date: Sat, 17 Sep 2022 10:19:31 +0200 Subject: [PATCH] Fix some web issues and cleanup (#2582) --- .../watch-video-playlist.js | 11 +----- src/renderer/views/Channel/Channel.js | 38 ++++++------------- src/renderer/views/Settings/Settings.vue | 4 +- src/renderer/views/Trending/Trending.js | 17 +++------ src/renderer/views/Watch/Watch.js | 15 ++------ 5 files changed, 25 insertions(+), 60 deletions(-) diff --git a/src/renderer/components/watch-video-playlist/watch-video-playlist.js b/src/renderer/components/watch-video-playlist/watch-video-playlist.js index 465e30f23..0aaf7d5ea 100644 --- a/src/renderer/components/watch-video-playlist/watch-video-playlist.js +++ b/src/renderer/components/watch-video-playlist/watch-video-playlist.js @@ -82,17 +82,10 @@ export default Vue.extend({ } }, mounted: function () { - if (!process.env.IS_ELECTRON) { + if (!process.env.IS_ELECTRON || this.backendPreference === 'invidious') { this.getPlaylistInformationInvidious() } else { - switch (this.backendPreference) { - case 'local': - this.getPlaylistInformationLocal() - break - case 'invidious': - this.getPlaylistInformationInvidious() - break - } + this.getPlaylistInformationLocal() } if ('mediaSession' in navigator) { diff --git a/src/renderer/views/Channel/Channel.js b/src/renderer/views/Channel/Channel.js index f25c0e19d..ebb899c89 100644 --- a/src/renderer/views/Channel/Channel.js +++ b/src/renderer/views/Channel/Channel.js @@ -181,20 +181,13 @@ export default Vue.extend({ this.apiUsed = '' this.isLoading = true - if (!process.env.IS_ELECTRON) { - this.getVideoInformationInvidious() + if (!process.env.IS_ELECTRON || this.backendPreference === 'invidious') { + this.getChannelInfoInvidious() + this.getPlaylistsInvidious() } else { - switch (this.backendPreference) { - case 'local': - this.getChannelInfoLocal() - this.getChannelVideosLocal() - this.getPlaylistsLocal() - break - case 'invidious': - this.getChannelInfoInvidious() - this.getPlaylistsInvidious() - break - } + this.getChannelInfoLocal() + this.getChannelVideosLocal() + this.getPlaylistsLocal() } }, @@ -237,20 +230,13 @@ export default Vue.extend({ this.currentTab = this.$route.params.currentTab ?? 'videos' this.isLoading = true - if (!process.env.IS_ELECTRON) { - this.getVideoInformationInvidious() + if (!process.env.IS_ELECTRON || this.backendPreference === 'invidious') { + this.getChannelInfoInvidious() + this.getPlaylistsInvidious() } else { - switch (this.backendPreference) { - case 'local': - this.getChannelInfoLocal() - this.getChannelVideosLocal() - this.getPlaylistsLocal() - break - case 'invidious': - this.getChannelInfoInvidious() - this.getPlaylistsInvidious() - break - } + this.getChannelInfoLocal() + this.getChannelVideosLocal() + this.getPlaylistsLocal() } }, methods: { diff --git a/src/renderer/views/Settings/Settings.vue b/src/renderer/views/Settings/Settings.vue index 0039eeacd..cd6b49553 100644 --- a/src/renderer/views/Settings/Settings.vue +++ b/src/renderer/views/Settings/Settings.vue @@ -7,7 +7,7 @@
-
+

@@ -19,7 +19,7 @@
-
+

diff --git a/src/renderer/views/Trending/Trending.js b/src/renderer/views/Trending/Trending.js index 4a5bd0333..7e89bc33c 100644 --- a/src/renderer/views/Trending/Trending.js +++ b/src/renderer/views/Trending/Trending.js @@ -97,17 +97,10 @@ export default Vue.extend({ }, getTrendingInfo () { - if (!process.env.IS_ELECTRON) { - this.getVideoInformationInvidious() + if (!process.env.IS_ELECTRON || this.backendPreference === 'invidious') { + this.getTrendingInfoInvidious() } else { - switch (this.backendPreference) { - case 'local': - this.getTrendingInfoLocal() - break - case 'invidious': - this.getTrendingInfoInvidious() - break - } + this.getTrendingInfoLocal() } }, @@ -142,7 +135,7 @@ export default Vue.extend({ navigator.clipboard.writeText(err) } }) - if (!process.env.IS_ELECTRON || (this.backendPreference === 'local' && this.backendFallback)) { + if (this.backendPreference === 'local' && this.backendFallback) { this.showToast({ message: this.$t('Falling back to Invidious API') }) @@ -202,7 +195,7 @@ export default Vue.extend({ } }) - if (!process.env.IS_ELECTRON || (this.backendPreference === 'invidious' && this.backendFallback)) { + if (process.env.IS_ELECTRON && (this.backendPreference === 'invidious' && this.backendFallback)) { this.showToast({ message: this.$t('Falling back to Local API') }) diff --git a/src/renderer/views/Watch/Watch.js b/src/renderer/views/Watch/Watch.js index 979df6cc9..37ebfa256 100644 --- a/src/renderer/views/Watch/Watch.js +++ b/src/renderer/views/Watch/Watch.js @@ -218,17 +218,10 @@ export default Vue.extend({ this.checkIfPlaylist() this.checkIfTimestamp() - if (!process.env.IS_ELECTRON) { + if (!process.env.IS_ELECTRON || this.backendPreference === 'invidious') { this.getVideoInformationInvidious() } else { - switch (this.backendPreference) { - case 'local': - this.getVideoInformationLocal() - break - case 'invidious': - this.getVideoInformationInvidious() - break - } + this.getVideoInformationLocal() } window.addEventListener('beforeunload', this.handleWatchProgress) @@ -588,7 +581,7 @@ export default Vue.extend({ } }) console.log(err) - if (!process.env.IS_ELECTRON || (this.backendPreference === 'local' && this.backendFallback && !err.toString().includes('private'))) { + if (this.backendPreference === 'local' && this.backendFallback && !err.toString().includes('private')) { this.showToast({ message: this.$t('Falling back to Invidious API') }) @@ -1151,7 +1144,7 @@ export default Vue.extend({ let url = `${this.currentInvidiousInstance}/api/manifest/dash/id/${this.videoId}` if (this.proxyVideos || !process.env.IS_ELECTRON) { - url = url + '?local=true' + url += '?local=true' } return [