Newer
Older
- @copyright Copyright (c) 2021 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"
@doSubscribe="doSubscribe" />
<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'
export default {
name: 'Show',
components: {
EmptyContent,
podcastId: null,
isSubscribed() {
return this.$store.getters.showExists(this.podcastId)
},
},
destroyed() {
window.removeEventListener('scroll', this.handleScroll)
isPlaying(episodeId) {
return this.$store.getters.isPlaying(episodeId)
},
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()
}
},
doSubscribe() {
if (this.isSubscribed) {
this.$store.dispatch('removeShow', this.podcast)
} else {
this.$store.dispatch('addShow', this.podcast)
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) {
if (this.isPlaying(episode.id)) {
this.$store.dispatch('pauseEpisode')
} else {
this.$store.dispatch('playEpisode', episode)
}
},
}
</script>
<style lang="scss">
margin-top: 10px !important;
.empty-content__icon {
margin-bottom: 0px !important;
}
}