diff --git a/src/components/MediaHeader.vue b/src/components/MediaHeader.vue index 4fc772f7138471e3ed89b3b77522b4ecc654dc5a..d376db0908b9120c518a556b881c34fa53617b2a 100644 --- a/src/components/MediaHeader.vue +++ b/src/components/MediaHeader.vue @@ -33,9 +33,10 @@ <div v-show="isshow" class="podcastControls"> - <button class="icon-add-white podcastButton button primary new-button" - @click="doSubscribe(podcastid, imgurl, title, author)"> - {{ t('podcast', 'Subscribe') }} + <button class="icon-add-white podcastButton button new-button" + :class="issubscribed ? 'icon-delete' : 'icon-add-white primary'" + @click="doSubscribe()"> + {{ getSubscribeText }} </button> <ul class="podcastCategory"> <a v-for="(category, idx) in categories" @@ -100,10 +101,23 @@ export default { type: Boolean, default: false, }, + issubscribed: { + type: Boolean, + default: false, + }, + }, + computed: { + getSubscribeText() { + if (this.issubscribed) { + return t('podcast', 'Unsubscribe') + } else { + return t('podcast', 'Subscribe') + } + }, }, methods: { - doSubscribe(podcastid, imgurl, title, author) { - this.$emit('doSubscribe', podcastid, imgurl, title, author) + doSubscribe() { + this.$emit('doSubscribe') }, getCategoryName(categoryid) { return getCategoryName(categoryid) diff --git a/src/views/Show.vue b/src/views/Show.vue index 89244b52767bda955387a0dda9bc1ea734576f0d..887c308353d556f2ea846b7122cfa514978264df 100644 --- a/src/views/Show.vue +++ b/src/views/Show.vue @@ -33,6 +33,7 @@ :description="podcast.description" :podcastid="podcast.id" :isshow="true" + :issubscribed="issubscribed" @doSubscribe="doSubscribe" /> <Table v-resize="onResize" @@ -78,6 +79,7 @@ export default { loading: true, nextPage: null, podcastId: null, + issubscribed: false, }), computed: { player() { @@ -133,21 +135,20 @@ export default { doPlay(episode) }, - async doSubscribe(podcastid, imgurl, title, author) { - console.log(podcastid, imgurl, title, author) + async doSubscribe() { const podcastShow = { id: -1, - podcastid, - imgurl, - title, - author, + podcastid: this.podcast.id, + imgurl: this.podcast.smallImageURL, + title: this.podcast.title, + author: this.podcast.author, } try { axios.defaults.headers.requesttoken = requesttoken await axios .post(generateUrl('/apps/podcast/api/shows'), podcastShow) .then(response => { - console.log('subscribed') + this.issubscribed = true }) } catch (error) { showError(t('podcast', 'Could not subscribe to podcast'))