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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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