From 73678be2c895a3487081b4e811810c8ac36cf1fb Mon Sep 17 00:00:00 2001 From: MasutaYunikon Date: Fri, 22 May 2026 20:56:50 +0200 Subject: [PATCH] =?UTF-8?q?fix:=20demandes=20d'=C3=A9pisode=20qui=20demand?= =?UTF-8?q?e=20toutes=20la=20serie?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/requests.ts | 18 ++++++++---------- src/views/DashboardView.vue | 26 ++++++++++++++++---------- src/views/SeriesView.vue | 16 ++++++++++------ 3 files changed, 34 insertions(+), 26 deletions(-) diff --git a/server/requests.ts b/server/requests.ts index 7abb2cd..440a5d6 100644 --- a/server/requests.ts +++ b/server/requests.ts @@ -94,18 +94,16 @@ export function upsertRequest( const idx = existing.requesters.findIndex(r => r.userId === userId) if (idx >= 0) { const r = existing.requesters[idx] - // Fusionner les saisons - if (seasons.length === 0 && episodes.length === 0) { - r.seasons = [] // "toutes" — efface toute granularité + // "Tout" = seasons=[] ET episodes=[] (aucune granularité) + const newIsAll = seasons.length === 0 && episodes.length === 0 + const curIsAll = r.seasons.length === 0 && (r.episodes ?? []).length === 0 + if (newIsAll || curIsAll) { + // Dès que l'une des deux est "toutes les saisons" → effacer la granularité + r.seasons = [] r.episodes = [] } else { - if (seasons.length === 0 || r.seasons.length === 0) { - r.seasons = [] // l'une des deux est "toutes" → toutes - } else { - r.seasons = [...new Set([...r.seasons, ...seasons])].sort((a, b) => a - b) - } - // Fusionner les épisodes (union simple) - r.episodes = [...new Set([...(r.episodes ?? []), ...episodes])].sort((a, b) => a - b) + r.seasons = [...new Set([...r.seasons, ...seasons ])].sort((a, b) => a - b) + r.episodes = [...new Set([...(r.episodes ?? []), ...episodes ])].sort((a, b) => a - b) } r.requestedAt = now } else { diff --git a/src/views/DashboardView.vue b/src/views/DashboardView.vue index 126efee..3d5ba33 100644 --- a/src/views/DashboardView.vue +++ b/src/views/DashboardView.vue @@ -2,7 +2,7 @@
-
+
Catalogue {{ stats.catalogue }} @@ -13,19 +13,19 @@ {{ stats.imported }} {{ stats.catalogue > 0 ? Math.round(stats.imported / stats.catalogue * 100) : 0 }}% du catalogue
-
+
En cours {{ stats.downloading }} téléchargements
-
+
Erreurs {{ stats.errors }} {{ stats.errors === 0 ? 'aucune erreur' : 'à corriger' }}
-
+
@@ -188,6 +188,7 @@ const loadingRequests = ref(true) let interval: ReturnType | null = null async function fetchSettings() { + if (!auth.isAdmin) return const res = await fetch('/api/settings', { credentials: 'include' }) if (res.ok) { const s = await res.json() @@ -203,10 +204,9 @@ async function fetchDebug() { async function fetchStats() { try { - const [statusRes, seriesRes, downloadsRes] = await Promise.all([ + const [statusRes, seriesRes] = await Promise.all([ fetch('/api/torrents/status', { credentials: 'include' }), fetch('/api/series', { credentials: 'include' }), - fetch('/api/downloads', { credentials: 'include' }), ]) if (statusRes.ok) { const s = await statusRes.json(); stats.value.catalogue = s.count ?? 0 } if (seriesRes.ok) { @@ -214,15 +214,20 @@ async function fetchStats() { const list = Array.isArray(s) ? s : (s.series ?? []) stats.value.imported = list.filter((s: any) => s.download_state === 'complete').length } - if (downloadsRes.ok) { - const torrents = await downloadsRes.json() - stats.value.downloading = torrents.filter((t: any) => t.state === 'downloading').length - stats.value.errors = torrents.filter((t: any) => t.state === 'error').length + // Stats téléchargements : admin uniquement + if (auth.isAdmin) { + const downloadsRes = await fetch('/api/downloads', { credentials: 'include' }) + if (downloadsRes.ok) { + const torrents = await downloadsRes.json() + stats.value.downloading = torrents.filter((t: any) => t.state === 'downloading').length + stats.value.errors = torrents.filter((t: any) => t.state === 'error').length + } } } catch {} } async function fetchTorrents() { + if (!auth.isAdmin) { loadingTorrents.value = false; return } const isFirst = loadingTorrents.value try { const res = await fetch('/api/downloads', { credentials: 'include' }) @@ -236,6 +241,7 @@ async function fetchTorrents() { } async function fetchNotifs() { + if (!auth.isAdmin) { loadingNotifs.value = false; return } loadingNotifs.value = true try { const res = await fetch('/api/organize/recent', { credentials: 'include' }) diff --git a/src/views/SeriesView.vue b/src/views/SeriesView.vue index 7599aeb..0f0d751 100644 --- a/src/views/SeriesView.vue +++ b/src/views/SeriesView.vue @@ -88,8 +88,9 @@ import { ref, computed, onMounted, onUnmounted, onActivated } from 'vue' import { RouterLink } from 'vue-router' import { Tv } from 'lucide-vue-next' -import { useSeriesStore } from '@/stores/series' +import { useSeriesStore } from '@/stores/series' import { useDownloadsStore } from '@/stores/downloads' +import { useAuthStore } from '@/stores/auth' import { useToast } from '@/composables/useToast' import { usePosterSize } from '@/composables/usePosterSize' import SeriesToolbar from '@/components/series/SeriesToolbar.vue' @@ -98,6 +99,7 @@ defineOptions({ name: 'SeriesView' }) const store = useSeriesStore() const dlStore = useDownloadsStore() +const auth = useAuthStore() const { add: toast } = useToast() const { current: posterSize, sizes: posterSizes } = usePosterSize() @@ -198,17 +200,19 @@ async function fetchOrganizeNotifs() { onMounted(async () => { if (store.series.length === 0) await store.fetchSeries() - dlStore.refresh() - fetchOrganizeNotifs() - dlInterval = setInterval(() => { + if (auth.isAdmin) { dlStore.refresh() fetchOrganizeNotifs() - }, 10000) + dlInterval = setInterval(() => { + dlStore.refresh() + fetchOrganizeNotifs() + }, 10000) + } }) onActivated(async () => { store.fetchSeries() - dlStore.refresh() + if (auth.isAdmin) dlStore.refresh() }) onUnmounted(() => {