refacto: rework how toUrl works and fix modal redirection after close
All checks were successful
repod / xml (push) Successful in 17s
repod / php (push) Successful in 54s
repod / nodejs (push) Successful in 2m0s
repod / release (push) Has been skipped

This commit is contained in:
Michel Roux 2024-01-11 22:03:32 +01:00
parent 0bbe6dbf24
commit 615f9e0c49
7 changed files with 20 additions and 27 deletions

View File

@ -1,7 +1,7 @@
<template>
<ul class="bar">
<NcAppNavigationNewItem :name="t('repod', 'Add a RSS link')"
@new-item="addSubscription">
@new-item="$router.push(encodeUrl(feedUrl))">
<template #icon>
<Plus :size="20" />
</template>
@ -21,9 +21,7 @@ export default {
Plus,
},
methods: {
addSubscription(feedUrl) {
this.$router.push(encodeUrl(feedUrl))
},
encodeUrl,
},
}
</script>

View File

@ -26,10 +26,10 @@ import AdaptativeList from '../Atoms/AdaptativeList.vue'
import Loading from '../Atoms/Loading.vue'
import axios from '@nextcloud/axios'
import { debounce } from '../../utils/debounce.js'
import { encodeUrl } from '../../utils/url.js'
import { generateUrl } from '@nextcloud/router'
import moment from '@nextcloud/moment'
import { showError } from '@nextcloud/dialogs'
import { toUrl } from '../../utils/url.js'
export default {
name: 'Search',
@ -58,6 +58,7 @@ export default {
},
methods: {
moment,
toUrl,
search: debounce(async function value() {
try {
this.loading = true
@ -75,9 +76,6 @@ export default {
}
}
}, 200),
toUrl(url) {
return `/${encodeUrl(url)}`
},
},
}
</script>

View File

@ -1,11 +1,11 @@
<template>
<router-link :to="toUrl">
<router-link :to="toUrl(link)">
<img :src="imageUrl" :title="author">
</router-link>
</template>
<script>
import { encodeUrl } from '../../utils/url.js'
import { toUrl } from '../../utils/url.js'
export default {
name: 'TopItem',
@ -27,10 +27,8 @@ export default {
required: true,
},
},
computed: {
toUrl() {
return `/${encodeUrl(this.link)}`
},
methods: {
toUrl,
},
}
</script>

View File

@ -36,7 +36,7 @@
</NcListItem>
</AdaptativeList>
<NcModal v-if="modalEpisode"
@close="modalEpisode = null">
@close="closeModal">
<Modal :description="modalEpisode.description"
:image="modalEpisode.image"
:link="modalEpisode.link"
@ -49,13 +49,13 @@
<script>
import { NcActionButton, NcAvatar, NcListItem, NcModal } from '@nextcloud/vue'
import { decodeUrl, encodeUrl } from '../../utils/url.js'
import AdaptativeList from '../Atoms/AdaptativeList.vue'
import Loading from '../Atoms/Loading.vue'
import Modal from './Modal.vue'
import PlayButton from 'vue-material-design-icons/Play.vue'
import StopButton from 'vue-material-design-icons/Stop.vue'
import axios from '@nextcloud/axios'
import { decodeUrl } from '../../utils/url.js'
import { formatTimer } from '../../utils/time.js'
import { generateUrl } from '@nextcloud/router'
import moment from '@nextcloud/moment'
@ -110,6 +110,10 @@ export default {
load(episode) {
this.$store.dispatch('player/load', episode)
},
closeModal() {
this.modalEpisode = null
this.$router.push(encodeUrl(this.url))
},
},
}
</script>

View File

@ -10,7 +10,7 @@
</template>
<script>
import { encodeUrl } from '../../utils/url.js'
import { toUrl } from '../../utils/url.js'
export default {
name: 'Infos',
@ -20,9 +20,7 @@ export default {
},
},
methods: {
toUrl(url) {
return `/${encodeUrl(url)}`
},
toUrl,
},
}
</script>

View File

@ -1,7 +1,7 @@
<template>
<NcAppNavigationItem :loading="loading"
:name="feed ? feed.title : url"
:to="toUrl">
:to="toUrl(url)">
<template #icon>
<NcAvatar v-if="feed"
:display-name="feed.author"
@ -25,9 +25,9 @@ import { NcActionButton, NcAppNavigationItem, NcAvatar } from '@nextcloud/vue'
import Alert from 'vue-material-design-icons/Alert.vue'
import Delete from 'vue-material-design-icons/Delete.vue'
import axios from '@nextcloud/axios'
import { encodeUrl } from '../../utils/url.js'
import { generateUrl } from '@nextcloud/router'
import { showError } from '@nextcloud/dialogs'
import { toUrl } from '../../utils/url.js'
export default {
name: 'Item',
@ -51,11 +51,6 @@ export default {
feed: null,
}
},
computed: {
toUrl() {
return `/${encodeUrl(this.url)}`
},
},
async mounted() {
try {
const podcastData = await axios.get(generateUrl('/apps/gpoddersync/personal_settings/podcast_data?url={url}', { url: this.url }))
@ -68,6 +63,7 @@ export default {
}
},
methods: {
toUrl,
async deleteSubscription() {
if (confirm(t('repod', 'Are you sure you want to delete this subscription?'))) {
try {

View File

@ -1,2 +1,3 @@
export const encodeUrl = (url) => encodeURIComponent(btoa(url))
export const decodeUrl = (url) => atob(decodeURIComponent(url))
export const toUrl = (url) => `/${encodeUrl(url)}`