Newer
Older
<!--
- @copyright Copyright (c) 2020 Jonas Heinrich
-
- @author Jonas Heinrich <onny@project-insanity.org>
-
- @license GNU AGPL version 3 or any later version
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU Affero General Public License as
- published by the Free Software Foundation, either version 3 of the
- License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Affero General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-->
<template>
<ShowEmpty v-show="loading" />
<div v-show="!loading">
<MediaHeader
:imgurl="podcast.smallImageURL"
:title="podcast.title"
:author="podcast.author"
:podcastid="podcast.id"
:isshow="true"
<EmptyContent
icon="icon-loading"
class="tableLoading" />
</template>
<script>
import Table from '../components/Table'
import MediaHeader from '../components/MediaHeader'
import EmptyContent from '@nextcloud/vue/dist/Components/EmptyContent'
import ShowEmpty from './placeholder/Show'
import { audioPlayer, doPlay } from '../services/player'
import { ShowApi } from './../services/ShowApi'
import { FyydApi } from './../services/FyydApi'
const fyydClient = new FyydApi()
const apiClient = new ShowApi()
export default {
name: 'Show',
components: {
EmptyContent,
podcastId: null,
return this.episodes.length === 0 // FIXME: also consider podcast object
player() {
return this.$store.state.player
},
},
watch: {
'player.volume'(newVolume, oldVolume) {
if (audioPlayer !== null) {
audioPlayer.volume(newVolume)
}
},
'player.isPaused'(newState, oldState) {
if (newState === true && audioPlayer !== null) {
audioPlayer.pause()
} else if (newState === false && audioPlayer !== null) {
audioPlayer.play()
}
},
},
mounted() {
},
destroyed() {
window.removeEventListener('scroll', this.handleScroll)
init() {
this.podcast = {}
this.episodes = []
this.page = 0
this.podcastId = this.$route.params.id
window.addEventListener('scroll', this.handleScroll)
this.queryPodcast(this.podcastId)
this.queryEpisodes(this.podcastId, this.page)
},
onResize({ width, height }) {
const rect = document.getElementsByClassName('episodeTable')[0].getBoundingClientRect()
console.log(rect.top, rect.right, rect.bottom, rect.left)
const contentHeight = document.getElementById('app-content-vue').scrollHeight
const tableHeight = height
if (tableHeight < contentHeight) {
this.preFill()
}
},
doPlay(episode) {
doPlay(episode)
},
if (this.issubscribed) {
await apiClient.removeShow(this.podcast)
this.issubscribed = false
} else {
await apiClient.addShow(this.podcast)
this.issubscribed = true
}
console.log('prefilling')
// this.queryPodcast(podcastId)
},
async queryPodcast(podcastId) {
const podcast = await fyydClient.queryPodcast(podcastId)
this.processPodcast(podcast.data)
async queryEpisodes(podcastId, page) {
const episodes = await fyydClient.queryEpisodes(podcastId, page)
this.episodes = this.episodes.concat(episodes.data.episodes)
if (episodes.meta.paging.next_page === null) {
this.page = null
window.removeEventListener('scroll', this.handleScroll)
} else {
},
processPodcast(podcast) {
this.podcast = podcast
document.title = podcast.title + ' - Podcast - Nextcloud'
* On scroll event, load more episodes if bottom reached
handleScroll() {
if ((window.innerHeight + window.scrollY) >= document.body.scrollHeight) {
if (!this.episodesLoaded) {
}
},
},
}
</script>
<style lang="scss">
margin-top: 10px !important;
.empty-content__icon {
margin-bottom: 0px !important;
}
}