Forgot to commit search file and fix PiP logic when history is disabled

This commit is contained in:
Preston 2021-01-21 16:20:42 -05:00
parent 2ac6a81699
commit 3150f25506
2 changed files with 30 additions and 8 deletions

View File

@ -16,6 +16,8 @@ export default Vue.extend({
data: function () { data: function () {
return { return {
isLoading: false, isLoading: false,
apiUsed: 'local',
amountOfResults: 0,
query: '', query: '',
searchPage: 1, searchPage: 1,
nextPageRef: '', nextPageRef: '',
@ -122,6 +124,10 @@ export default Vue.extend({
return return
} }
this.apiUsed = 'local'
this.amountOfResults = result.results
const returnData = result.items.filter((item) => { const returnData = result.items.filter((item) => {
if (typeof item !== 'undefined') { if (typeof item !== 'undefined') {
return item.type === 'video' || item.type === 'channel' || item.type === 'playlist' return item.type === 'video' || item.type === 'channel' || item.type === 'playlist'
@ -179,7 +185,8 @@ export default Vue.extend({
query: payload.query, query: payload.query,
data: this.shownResults, data: this.shownResults,
searchSettings: this.searchSettings, searchSettings: this.searchSettings,
nextPageRef: result.continuation nextPageRef: result.continuation,
amountOfResults: result.results
} }
this.$store.commit('addToSessionSearchHistory', historyPayload) this.$store.commit('addToSessionSearchHistory', historyPayload)
@ -228,6 +235,8 @@ export default Vue.extend({
return return
} }
this.apiUsed = 'invidious'
console.log(result) console.log(result)
const returnData = result.filter((item) => { const returnData = result.filter((item) => {
@ -287,13 +296,21 @@ export default Vue.extend({
console.log(payload) console.log(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({ this.showToast({
message: this.$t('Search Filters["Fetching results. Please wait"]') message: this.$t('Search Filters["Fetching results. Please wait"]')
}) })
if (this.nextPageRef !== '') {
this.performSearchLocal(payload) this.performSearchLocal(payload)
}
} else { } else {
this.showToast({
message: this.$t('Search Filters["Fetching results. Please wait"]')
})
this.performSearchInvidious(payload) this.performSearchInvidious(payload)
} }
}, },
@ -302,6 +319,7 @@ export default Vue.extend({
this.query = history.query this.query = history.query
this.shownResults = history.data this.shownResults = history.data
this.searchSettings = history.searchSettings this.searchSettings = history.searchSettings
this.amountOfResults = history.amountOfResults
if (typeof (history.nextPageRef) !== 'undefined') { if (typeof (history.nextPageRef) !== 'undefined') {
this.nextPageRef = history.nextPageRef this.nextPageRef = history.nextPageRef

View File

@ -864,12 +864,16 @@ export default Vue.extend({
console.log('update watch progress') console.log('update watch progress')
this.updateWatchProgress(payload) this.updateWatchProgress(payload)
} }
}
if (!this.isUpcoming && !this.isLoading) {
const player = this.$refs.videoPlayer.player
if (player !== null && !player.paused() && player.isInPictureInPicture()) { if (player !== null && !player.paused() && player.isInPictureInPicture()) {
const playerId = this.videoId const playerId = this.videoId
setTimeout(() => { setTimeout(() => {
player.play() player.play()
player.on('leavepictureinpicture', () => { player.on('leavepictureinpicture', (event) => {
const watchTime = player.currentTime() const watchTime = player.currentTime()
if (this.$route.fullPath.includes('/watch')) { if (this.$route.fullPath.includes('/watch')) {
const routeId = this.$route.params.id const routeId = this.$route.params.id