2023-07-10 00:25:32 +02:00
|
|
|
<template>
|
|
|
|
<NcAppNavigationItem :loading="loading"
|
|
|
|
:title="title ?? subscriptionUrl">
|
|
|
|
<template #icon>
|
|
|
|
<img v-if="imageUrl"
|
|
|
|
:src="imageUrl"
|
|
|
|
:alt="title"
|
|
|
|
width="20"
|
|
|
|
height="20">
|
|
|
|
<Alert v-if="failed" />
|
|
|
|
</template>
|
2023-07-25 22:19:16 +02:00
|
|
|
<template #actions>
|
|
|
|
<NcActionButton @click="deleteSubscription">
|
|
|
|
<template #icon>
|
|
|
|
<Delete :size="20" />
|
|
|
|
</template>
|
|
|
|
{{ t('Delete') }}
|
|
|
|
</NcActionButton>
|
|
|
|
</template>
|
2023-07-10 00:25:32 +02:00
|
|
|
</NcAppNavigationItem>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2023-07-25 22:19:16 +02:00
|
|
|
import { NcActionButton, NcAppNavigationItem } from '@nextcloud/vue'
|
2023-07-10 00:25:32 +02:00
|
|
|
import Alert from 'vue-material-design-icons/Alert.vue'
|
2023-07-25 22:19:16 +02:00
|
|
|
import Delete from 'vue-material-design-icons/Delete.vue'
|
2023-07-10 00:25:32 +02:00
|
|
|
import axios from '@nextcloud/axios'
|
|
|
|
import { generateUrl } from '@nextcloud/router'
|
2023-07-25 22:19:16 +02:00
|
|
|
import { showError } from '@nextcloud/dialogs'
|
2023-07-10 00:25:32 +02:00
|
|
|
|
|
|
|
export default {
|
|
|
|
name: 'SubscriptionListItem',
|
|
|
|
components: {
|
|
|
|
Alert,
|
2023-07-25 22:19:16 +02:00
|
|
|
Delete,
|
|
|
|
NcActionButton,
|
2023-07-10 00:25:32 +02:00
|
|
|
NcAppNavigationItem,
|
|
|
|
},
|
|
|
|
props: {
|
|
|
|
subscriptionUrl: {
|
|
|
|
type: String,
|
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
failed: false,
|
|
|
|
loading: true,
|
|
|
|
title: null,
|
|
|
|
imageUrl: null,
|
|
|
|
}
|
|
|
|
},
|
|
|
|
async mounted() {
|
|
|
|
try {
|
|
|
|
const podcastData = await axios.get(generateUrl('/apps/gpoddersync/personal_settings/podcast_data?url={url}', { url: this.subscriptionUrl }))
|
|
|
|
this.title = podcastData.data.data.title
|
|
|
|
this.imageUrl = podcastData.data.data.imageUrl
|
|
|
|
} catch (e) {
|
|
|
|
this.failed = true
|
|
|
|
console.error(e)
|
|
|
|
} finally {
|
|
|
|
this.loading = false
|
|
|
|
}
|
|
|
|
},
|
2023-07-25 22:19:16 +02:00
|
|
|
methods: {
|
|
|
|
async deleteSubscription() {
|
|
|
|
try {
|
2023-07-28 01:52:48 +02:00
|
|
|
this.loading = true
|
2023-07-25 22:19:16 +02:00
|
|
|
await axios.post(generateUrl('/apps/gpoddersync/subscription_change/create'), { add: [], remove: [this.subscriptionUrl] })
|
|
|
|
} catch (e) {
|
|
|
|
console.error(e)
|
|
|
|
showError(t('Error while removing the feed'))
|
2023-07-28 01:52:48 +02:00
|
|
|
} finally {
|
|
|
|
this.loading = false
|
|
|
|
this.$store.dispatch('subscriptions/fetch')
|
2023-07-25 22:19:16 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
2023-07-10 00:25:32 +02:00
|
|
|
}
|
|
|
|
</script>
|