From 3150f25506f835770044754e4d1862c7c94d674b Mon Sep 17 00:00:00 2001 From: Preston Date: Thu, 21 Jan 2021 16:20:42 -0500 Subject: [PATCH] Forgot to commit search file and fix PiP logic when history is disabled --- src/renderer/views/Search/Search.js | 32 ++++++++++++++++++++++------- src/renderer/views/Watch/Watch.js | 6 +++++- 2 files changed, 30 insertions(+), 8 deletions(-) diff --git a/src/renderer/views/Search/Search.js b/src/renderer/views/Search/Search.js index c0328929b..16855e454 100644 --- a/src/renderer/views/Search/Search.js +++ b/src/renderer/views/Search/Search.js @@ -16,6 +16,8 @@ export default Vue.extend({ data: function () { return { isLoading: false, + apiUsed: 'local', + amountOfResults: 0, query: '', searchPage: 1, nextPageRef: '', @@ -122,6 +124,10 @@ export default Vue.extend({ return } + this.apiUsed = 'local' + + this.amountOfResults = result.results + const returnData = result.items.filter((item) => { if (typeof item !== 'undefined') { return item.type === 'video' || item.type === 'channel' || item.type === 'playlist' @@ -179,7 +185,8 @@ export default Vue.extend({ query: payload.query, data: this.shownResults, searchSettings: this.searchSettings, - nextPageRef: result.continuation + nextPageRef: result.continuation, + amountOfResults: result.results } this.$store.commit('addToSessionSearchHistory', historyPayload) @@ -228,6 +235,8 @@ export default Vue.extend({ return } + this.apiUsed = 'invidious' + console.log(result) const returnData = result.filter((item) => { @@ -287,13 +296,21 @@ export default Vue.extend({ console.log(payload) - this.showToast({ - message: this.$t('Search Filters["Fetching results. Please wait"]') - }) - - if (this.nextPageRef !== '') { - this.performSearchLocal(payload) + if (this.apiUsed === 'local') { + if (this.amountOfResults <= this.shownResults.length) { + this.showToast({ + message: this.$t('Search Filters.There are no more results for this search') + }) + } else { + this.showToast({ + message: this.$t('Search Filters["Fetching results. Please wait"]') + }) + this.performSearchLocal(payload) + } } else { + this.showToast({ + message: this.$t('Search Filters["Fetching results. Please wait"]') + }) this.performSearchInvidious(payload) } }, @@ -302,6 +319,7 @@ export default Vue.extend({ this.query = history.query this.shownResults = history.data this.searchSettings = history.searchSettings + this.amountOfResults = history.amountOfResults if (typeof (history.nextPageRef) !== 'undefined') { this.nextPageRef = history.nextPageRef diff --git a/src/renderer/views/Watch/Watch.js b/src/renderer/views/Watch/Watch.js index e1e19785d..683885303 100644 --- a/src/renderer/views/Watch/Watch.js +++ b/src/renderer/views/Watch/Watch.js @@ -864,12 +864,16 @@ export default Vue.extend({ console.log('update watch progress') this.updateWatchProgress(payload) } + } + + if (!this.isUpcoming && !this.isLoading) { + const player = this.$refs.videoPlayer.player if (player !== null && !player.paused() && player.isInPictureInPicture()) { const playerId = this.videoId setTimeout(() => { player.play() - player.on('leavepictureinpicture', () => { + player.on('leavepictureinpicture', (event) => { const watchTime = player.currentTime() if (this.$route.fullPath.includes('/watch')) { const routeId = this.$route.params.id