feat: utilisation des bar de telechargement par fichier dans le torrent plutot que celui du torrent

This commit is contained in:
MasutaYunikon committed 2026-04-21 15:53:39 +02:00
1 parent 4955a730b7
commit 7e53bab0fc
6 files changed
+87 -26

No files matched your search

+18 -6
View File
@@ -158,7 +158,7 @@
import { ref, computed, h } from 'vue'
import { ChevronUp, Download, Loader, Check, X } from 'lucide-vue-next'
interface ActiveTorrent { hash: string; progress: number; state: string }
interface ActiveTorrent { hash: string; progress: number; state: string; files?: { index: number; progress: number }[] }
const props = defineProps<{
season : any
@@ -232,13 +232,25 @@ const seasonBtnIcon = computed(() => {
// ── État épisode ───────────────────────────────────────────────
function epProgress(ep: any): ActiveTorrent | null {
// Un épisode déjà dans la bibliothèque n'a jamais besoin d'une barre de progression.
if (ep.organized) return null
const torrent = torrentProgress(extractHash(ep.torrent))
if (!torrent) return null
if (ep.torrent?.file_index != null) {
// Épisode dans un pack : le hash est partagé par tous les épisodes du pack.
// On affiche la progression du pack UNIQUEMENT pour cet épisode s'il a été
// explicitement téléchargé dans cette session (isDownloaded).
return isDownloaded(`ep-${ep.id}`) ? torrentProgress(extractHash(ep.torrent)) : null
// Épisode dans un pack : on n'affiche que si téléchargé dans cette session.
if (!isDownloaded(`ep-${ep.id}`)) return null
// Si le client remonte la progression par fichier, on utilise celle du fichier précis
// plutôt que la progression globale du pack.
if (torrent.files && torrent.files.length > 0) {
const file = torrent.files.find(f => f.index === ep.torrent.file_index)
if (file != null) return { ...torrent, progress: file.progress }
}
return torrent
}
return torrentProgress(extractHash(ep.torrent))
return torrent
}
function epState(ep: any): 'idle' | 'loading' | 'done' | 'unavailable' {
+2 -2
View File
@@ -133,7 +133,7 @@ const epActionLoading = ref<Record<number, boolean>>({})
const downloadingAll = ref(false)
const downloadingSeason = ref<Record<number, boolean>>({})
interface ActiveTorrent { hash: string; progress: number; state: string }
export interface ActiveTorrent { hash: string; progress: number; state: string; files?: { index: number; progress: number }[] }
const activeTorrents = ref<ActiveTorrent[]>([])
let pollTimer: ReturnType<typeof setInterval> | null = null
@@ -192,7 +192,7 @@ async function fetchActiveDownloads() {
const res = await fetch('/api/downloads', { credentials: 'include' })
if (!res.ok) return
const list: any[] = await res.json()
activeTorrents.value = list.map(t => ({ hash: t.hash, progress: t.progress ?? 0, state: t.state }))
activeTorrents.value = list.map(t => ({ hash: t.hash, progress: t.progress ?? 0, state: t.state, files: t.files }))
} catch {}
}