style: 🧑‍💻 update types ont loop functions
All checks were successful
repod / xml (push) Successful in 18s
repod / php (push) Successful in 58s
repod / nodejs (push) Successful in 1m7s
repod / release (push) Has been skipped

This commit is contained in:
Michel Roux 2024-12-11 21:43:22 +01:00
parent 75b9e05999
commit 6cd1058048
8 changed files with 53 additions and 37 deletions

View File

@ -2,7 +2,7 @@
<NcAppNavigationList class="list">
<NcAppNavigationNewItem
:name="t('repod', 'Add a RSS link')"
@new-item="(url) => $router.push(toFeedUrl(url))">
@new-item="(url: string) => $router.push(toFeedUrl(url))">
<template #icon>
<PlusIcon :size="20" />
</template>

View File

@ -110,7 +110,8 @@ export default {
)
if (currentSearch === this.value) {
this.feeds = [...feeds.data].sort(
(a, b) => b.fetchedAtUnix - a.fetchedAtUnix,
(a: PodcastDataInterface, b: PodcastDataInterface) =>
b.fetchedAtUnix - a.fetchedAtUnix,
)
}
} catch (e) {

View File

@ -3,7 +3,7 @@
<Loading v-if="loading" />
<ul v-if="!loading">
<NcListItem
v-if="!episodes.every((e) => !e.selected)"
v-if="!episodes.every((e: EpisodeInterface) => !e.selected)"
:active="true"
:force-display-actions="true"
:name="
@ -11,7 +11,7 @@
'repod',
'%n episode selected',
'%n episodes selected',
episodes.filter((e) => e.selected).length,
episodes.filter((e: EpisodeInterface) => e.selected).length,
)
"
:one-line="true">
@ -19,14 +19,14 @@
<NcActionButton
v-if="
episodes
.filter((e) => e.selected)
.filter((e) => !hasEnded(e)).length
.filter((e: EpisodeInterface) => e.selected)
.filter((e: EpisodeInterface) => !hasEnded(e)).length
"
:aria-label="t('repod', 'Read all')"
:disabled="
!episodes
.filter((e) => e.selected)
.every((e) => e.duration)
.filter((e: EpisodeInterface) => e.selected)
.every((e: EpisodeInterface) => e.duration)
"
:name="t('repod', 'Read all')"
:title="t('repod', 'Read all')"
@ -38,14 +38,14 @@
<NcActionButton
v-if="
episodes
.filter((e) => e.selected)
.every((e) => hasEnded(e))
.filter((e: EpisodeInterface) => e.selected)
.every((e: EpisodeInterface) => hasEnded(e))
"
:aria-label="t('repod', 'Unread all')"
:disabled="
!episodes
.filter((e) => e.selected)
.every((e) => e.duration)
.filter((e: EpisodeInterface) => e.selected)
.every((e: EpisodeInterface) => e.duration)
"
:name="t('repod', 'Unread all')"
:title="t('repod', 'Unread all')"
@ -58,8 +58,8 @@
<template #icon>
<NcAvatar
v-if="
episodes.filter((e) => e.selected).length <
episodes.length
episodes.filter((e: EpisodeInterface) => e.selected)
.length < episodes.length
"
:display-name="t('repod', 'Select all')"
:is-no-user="true">
@ -72,8 +72,8 @@
</NcAvatar>
<NcAvatar
v-if="
episodes.filter((e) => e.selected).length >=
episodes.length
episodes.filter((e: EpisodeInterface) => e.selected)
.length >= episodes.length
"
:display-name="t('repod', 'Unselect all')"
:is-no-user="true">
@ -89,7 +89,9 @@
<Episode
v-for="episode in filteredEpisodes"
:key="episode.guid"
:display-actions="episodes.every((e) => !e.selected)"
:display-actions="
episodes.every((e: EpisodeInterface) => !e.selected)
"
:episode="episode"
:url="url"
@select="episode.selected = !episode.selected" />
@ -137,7 +139,7 @@ export default {
...mapState(usePlayer, ['episode']),
...mapState(useSettings, ['filters']),
filteredEpisodes() {
return this.episodes.filter((episode) => {
return this.episodes.filter((episode: EpisodeInterface) => {
if (!this.filters.listened && this.hasEnded(episode)) {
return false
}
@ -157,7 +159,7 @@ export default {
watch: {
episode() {
if (this.episode) {
this.episodes = this.episodes.map((episode) =>
this.episodes = this.episodes.map((episode: EpisodeInterface) =>
episode.url === this.episode?.url ? this.episode : episode,
)
}
@ -172,7 +174,7 @@ export default {
}),
)
this.episodes = [...episodes.data].sort(
(a, b) =>
(a: EpisodeInterface, b: EpisodeInterface) =>
new Date(b.pubDate?.date || '').getTime() -
new Date(a.pubDate?.date || '').getTime(),
)
@ -190,14 +192,14 @@ export default {
t,
async read(read: boolean) {
try {
this.episodes = this.episodes.map((episode) =>
this.episodes = this.episodes.map((episode: EpisodeInterface) =>
episode.selected ? markAs(episode, read, this.url) : episode,
)
await axios.post(
generateUrl('/apps/gpoddersync/episode_action/create'),
this.episodes
.filter((episode) => episode.selected)
.map((episode) => episode.action),
.filter((episode: EpisodeInterface) => episode.selected)
.map((episode: EpisodeInterface) => episode.action),
)
} catch (e) {
console.error(e)
@ -205,7 +207,7 @@ export default {
}
},
select(all: boolean) {
this.episodes = this.episodes.map((episode) => {
this.episodes = this.episodes.map((episode: EpisodeInterface) => {
episode.selected = all
return episode
})

View File

@ -63,11 +63,11 @@ export default {
)
this.episodes = [...episodes.data]
.sort(
(a, b) =>
(a: EpisodeInterface, b: EpisodeInterface) =>
new Date(b.pubDate?.date || '').getTime() -
new Date(a.pubDate?.date || '').getTime(),
)
.filter((episode) => !this.hasEnded(episode))
.filter((episode: EpisodeInterface) => !this.hasEnded(episode))
.slice(0, 4)
} catch (e) {
console.error(e)

View File

@ -39,10 +39,13 @@
<script lang="ts">
import { NcActionButton, NcAppNavigationItem, NcAvatar } from '@nextcloud/vue'
import type {
PersonalSettingsPodcastDataInterface,
SubscriptionInterface,
} from '../../utils/types.ts'
import { mapActions, mapState } from 'pinia'
import AlertIcon from 'vue-material-design-icons/Alert.vue'
import DeleteIcon from 'vue-material-design-icons/Delete.vue'
import type { PersonalSettingsPodcastDataInterface } from '../../utils/types.ts'
import StarIcon from 'vue-material-design-icons/Star.vue'
import StarPlusIcon from 'vue-material-design-icons/StarPlus.vue'
import StarRemoveIcon from 'vue-material-design-icons/StarRemove.vue'
@ -128,7 +131,10 @@ export default {
},
switchFavorite(value: boolean) {
if (value) {
if (this.subs.filter((sub) => sub.isFavorite).length >= 10) {
if (
this.subs.filter((sub: SubscriptionInterface) => sub.isFavorite)
.length >= 10
) {
showError(t('repod', 'You can only have 10 favorites'))
return
}

View File

@ -1,6 +1,7 @@
import type {
PersonalSettingsMetricsInterface,
PodcastDataInterface,
PodcastMetricsInterface,
SubscriptionInterface,
} from '../utils/types.ts'
import { getCookie, setCookie } from '../utils/cookies.ts'
@ -14,7 +15,7 @@ export const useSubscriptions = defineStore('subscriptions', {
}),
getters: {
getSubByUrl: (state) => (url: string) =>
state.subs.find((sub) => sub.metrics.url === url),
state.subs.find((sub: SubscriptionInterface) => sub.metrics.url === url),
},
actions: {
async fetch() {
@ -28,20 +29,23 @@ export const useSubscriptions = defineStore('subscriptions', {
)
this.subs = [...metrics.data.subscriptions]
.sort((a, b) => b.listenedSeconds - a.listenedSeconds)
.map((sub) => ({
.sort(
(a: PodcastMetricsInterface, b: PodcastMetricsInterface) =>
b.listenedSeconds - a.listenedSeconds,
)
.map((sub: PodcastMetricsInterface) => ({
metrics: sub,
isFavorite: favorites.includes(sub.url),
data: this.getSubByUrl(sub.url)?.data,
}))
},
addMetadatas(link: string, data: PodcastDataInterface) {
this.subs = this.subs.map((sub) =>
this.subs = this.subs.map((sub: SubscriptionInterface) =>
sub.metrics.url === link ? { ...sub, data } : sub,
)
},
setFavorite(link: string, isFavorite: boolean) {
this.subs = this.subs.map((sub) =>
this.subs = this.subs.map((sub: SubscriptionInterface) =>
sub.metrics.url === link ? { ...sub, isFavorite } : sub,
)
@ -49,8 +53,8 @@ export const useSubscriptions = defineStore('subscriptions', {
'repod.favorites',
JSON.stringify(
this.subs
.filter((sub) => sub.isFavorite)
.map((sub) => sub.metrics.url),
.filter((sub: SubscriptionInterface) => sub.isFavorite)
.map((sub: SubscriptionInterface) => sub.metrics.url),
),
365,
)

View File

@ -6,7 +6,9 @@
*/
export const getCookie = (name: string): string | null => {
const cookies = document.cookie.split('; ')
const value = cookies.find((c) => c.startsWith(name + '='))?.split('=')[1]
const value = cookies
.find((c: string) => c.startsWith(name + '='))
?.split('=')[1]
if (value === undefined) {
return null
}

View File

@ -24,6 +24,7 @@ import AppContent from '../components/Atoms/AppContent.vue'
import EmptyContent from '../components/Atoms/EmptyContent.vue'
import Favorite from '../components/Feed/Favorite.vue'
import StarOffIcon from 'vue-material-design-icons/StarOff.vue'
import type { SubscriptionInterface } from '../utils/types.ts'
import { mapState } from 'pinia'
import { t } from '@nextcloud/l10n'
import { useSubscriptions } from '../store/subscriptions.ts'
@ -39,7 +40,7 @@ export default {
computed: {
...mapState(useSubscriptions, ['subs']),
favorites() {
return this.subs.filter((sub) => sub.isFavorite)
return this.subs.filter((sub: SubscriptionInterface) => sub.isFavorite)
},
},
methods: {