Optimisation : cache, poids de l'app et code mort
deploy / deploy (push) Successful in 48s

- Affiches TMDB : on garde l'adresse au lieu de copier l'image dans la fiche (~50 Ko par fiche, renvoyés au serveur à chaque modification et chez les amis) ; le service worker les garde en cache pour le hors-ligne
- Service worker : pré-téléchargement réduit de 2 Mo à 1 Mo (les 17 autres langues, l'admin et les variantes de police sont mises en cache à la demande)
- Cache des fiches TMDB, saisons, personnes et notes Trakt (affichage immédiat, hors-ligne) ; caches d'images séparés (affiches / grandes images)
- React dans un fichier à part, gardé en cache d'une version à l'autre ; fichier principal 190 → 116 Ko compressés
- Chargés à la demande : assistant d'import (Réglages 73 → 25 Ko), dessin des cartes de partage, lecture des anciennes sauvegardes
- Code mort retiré ; base : extension pg_net (inutilisée) supprimée, index des notifications revus

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01YVo1qxKoBQCaMd7Ue8PGbe
This commit is contained in:
Claude committed 2026-11-29 13:13:59 +00:00
1 parent abcc12648e
commit c97a1d95c6
11 files changed
+120 -65

No files matched your search

+8 -4
View File
@@ -2,7 +2,6 @@ import { t } from '../i18n'
import type { BackupFile, Criteria, CustomList, MediaItem, MediaType, Settings, TopCategory, TopEntry, WatchStatus } from '../types'
import { ALL_TOP_CATEGORIES, MEDIA_TYPES, STATUSES } from './constants'
import { episodeCap } from './franchise'
import { convertLegacyBackup, isLegacyBackup } from './legacyImport'
import { cleanThemeMode } from './theme'
import {
cleanText,
@@ -225,9 +224,14 @@ export async function parseBackupFile(file: File): Promise<ParsedBackup> {
} catch {
throw new Error(t('backup.notJson'))
}
if (isLegacyBackup(data)) {
const legacy = convertLegacyBackup(data)
return { items: dedupe(legacy.items), skipped: legacy.skipped, format: 'legacy' }
// Ancien format (AzuuCine) : son convertisseur n'est chargé que pour ces fichiers-là
const first = isPlainObject(data) && Array.isArray(data.items) ? (data.items[0] as unknown) : undefined
if (isPlainObject(first) && ('tmdb_id' in first || 'media_type' in first || 'poster_path' in first)) {
const { convertLegacyBackup, isLegacyBackup } = await import('./legacyImport')
if (isLegacyBackup(data)) {
const legacy = convertLegacyBackup(data)
return { items: dedupe(legacy.items), skipped: legacy.skipped, format: 'legacy' }
}
}
const rawItems = Array.isArray(data) ? data : isPlainObject(data) && Array.isArray(data.items) ? data.items : null
if (!rawItems) throw new Error(t('backup.noItems'))
+2 -25
View File
@@ -1,8 +1,8 @@
import { t } from '../i18n'
import { LIMITS, safePosterUrl } from './security'
import { LIMITS } from './security'
/**
* Convertit une image (photo de la galerie, affiche téléchargée…) en petit JPEG
* Convertit une image (photo de la galerie) en petit JPEG
* compressé (data URL), pour garder la base légère et 100 % hors-ligne.
*/
export function blobToPosterDataURL(blob: Blob, maxWidth = 360, quality = 0.8): Promise<string> {
@@ -42,29 +42,6 @@ export function fileToPosterDataURL(file: File) {
return blobToPosterDataURL(file)
}
/**
* Télécharge une affiche distante et la garde en local (visible hors-ligne).
* Si le serveur refuse (CORS, réseau), on garde simplement l'URL.
*/
export async function remotePosterToLocal(url: string): Promise<string | undefined> {
const safe = safePosterUrl(url)
if (!safe || safe.startsWith('data:')) return safe
try {
const res = await fetch(safe, { mode: 'cors', credentials: 'omit', referrerPolicy: 'no-referrer', signal: AbortSignal.timeout(15_000) })
// Réponse en erreur ou annoncée trop grosse : on ne lit pas le corps
const announced = Number(res.headers.get('Content-Length'))
if (!res.ok || (Number.isFinite(announced) && announced > LIMITS.imageFileBytes)) {
await res.body?.cancel().catch(() => {})
return safe
}
const blob = await res.blob()
if (!blob.type.startsWith('image/') || blob.size > LIMITS.imageFileBytes) return safe
return await blobToPosterDataURL(blob)
} catch {
return safe
}
}
/**
* Photo de profil ou bannière : recadrée au centre aux dimensions voulues et ré-encodée en JPEG
* (aucune métadonnée cachée n'est conservée).
+2 -3
View File
@@ -1,5 +1,4 @@
import { findTmdbSeries, getAniListById, getTmdbDetails, releaseToResult, type GlobalRelease } from './catalogApi'
import { remotePosterToLocal } from './image'
import type { MediaInput } from '../types'
/**
@@ -13,7 +12,7 @@ export async function releaseToInput(r: GlobalRelease, tmdbKey?: string): Promis
const series = r.externalId.startsWith('anilist:') && hasKey ? await findTmdbSeries([r.title, r.originalTitle], tmdbKey!).catch(() => undefined) : undefined
if (series) {
data = await getTmdbDetails(series, tmdbKey!)
poster = series.posterUrl ? await remotePosterToLocal(series.posterUrl) : undefined
poster = series.posterUrl
} else if (r.externalId.startsWith('anilist:')) {
const res = await getAniListById(r.externalId)
data = { ...res?.prefill }
@@ -21,7 +20,7 @@ export async function releaseToInput(r: GlobalRelease, tmdbKey?: string): Promis
} else {
const res = releaseToResult(r)
if (res && hasKey) data = await getTmdbDetails(res, tmdbKey!)
poster = r.poster ? await remotePosterToLocal(r.poster) : undefined
poster = r.poster
}
return {
title: r.title,
-22
View File
@@ -423,28 +423,6 @@ export async function renderTopCard(title: string, entries: (MediaItem | undefin
return toBlob(canvas)
}
/** Ouvre la feuille de partage (mobile) ou télécharge l'image. */
export async function shareImage(blob: Blob, filename: string, title: string): Promise<'shared' | 'downloaded'> {
const file = new File([blob], filename, { type: 'image/png' })
if (navigator.canShare?.({ files: [file] })) {
try {
await navigator.share({ files: [file], title })
return 'shared'
} catch (e) {
if ((e as DOMException)?.name === 'AbortError') return 'shared'
}
}
const url = URL.createObjectURL(blob)
const a = document.createElement('a')
a.href = url
a.download = filename
document.body.appendChild(a)
a.click()
a.remove()
setTimeout(() => URL.revokeObjectURL(url), 2000)
return 'downloaded'
}
export const slug = (s: string) =>
s
.normalize('NFD')
+23
View File
@@ -0,0 +1,23 @@
// Petit module à part : la fenêtre d'aperçu l'importe directement, sans embarquer le dessin des cartes (shareCard, chargé à la demande).
/** Ouvre la feuille de partage (mobile) ou télécharge l'image. */
export async function shareImage(blob: Blob, filename: string, title: string): Promise<'shared' | 'downloaded'> {
const file = new File([blob], filename, { type: 'image/png' })
if (navigator.canShare?.({ files: [file] })) {
try {
await navigator.share({ files: [file], title })
return 'shared'
} catch (e) {
if ((e as DOMException)?.name === 'AbortError') return 'shared'
}
}
const url = URL.createObjectURL(blob)
const a = document.createElement('a')
a.href = url
a.download = filename
document.body.appendChild(a)
a.click()
a.remove()
setTimeout(() => URL.revokeObjectURL(url), 2000)
return 'downloaded'
}