Bibliothèque : tags perso, actions groupées et « Annuler »
- Tags personnels libres sur chaque titre (fiche → Mon suivi), affichés discrètement dans la fiche, filtre par tag dans le catalogue, suggestions = tags déjà utilisés. Synchronisés avec la fiche (JSON), inclus dans l'export/import (et repris des tags de l'ancienne appli). Privés : retirés par public_item (migration) et côté client. - Actions groupées dans le catalogue : appui long (mobile), case au survol (ordinateur) ou bouton « Sélectionner » ; tout sélectionner, compteur ; statut, listes (ajout / retrait), tag (ajout / retrait), suppression avec confirmation. Échap / retour quittent. - Toast global accessible (role=status) avec « Annuler » (~6 s) après suppression, changement de statut, retrait d'une liste, actions groupées. La restauration remet la fiche à l'identique avec un updatedAt plus récent que la suppression : la synchro LWW recrée bien la fiche côté serveur. - Store : updateMany, removeMany, restore. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01YVo1qxKoBQCaMd7Ue8PGbe
This commit is contained in:
35 files changed
+1795
-22
No files matched your search
+18
-1
@@ -18,7 +18,7 @@ import {
|
||||
safeSeasons,
|
||||
safeStringList,
|
||||
} from './security'
|
||||
import { todayISO, uid } from './utils'
|
||||
import { normalizeText, todayISO, uid } from './utils'
|
||||
|
||||
const TYPES = new Set<string>(MEDIA_TYPES.map((t) => t.value))
|
||||
const STATUS_SET = new Set<string>(STATUSES.map((s) => s.value))
|
||||
@@ -62,6 +62,21 @@ function safeDates(v: unknown): string[] | undefined {
|
||||
return out.length ? out : undefined
|
||||
}
|
||||
|
||||
/** Tags perso : texte court, sans doublon (casse et accents ignorés), 30 max. */
|
||||
export function safeTags(v: unknown): string[] | undefined {
|
||||
const seen = new Set<string>()
|
||||
const out: string[] = []
|
||||
for (const tag of safeStringList(v, LIMITS.tags * 2, LIMITS.tagLength)) {
|
||||
const s = tag.replace(/\s+/g, ' ').replace(/^#+/, '').trim()
|
||||
const key = normalizeText(s)
|
||||
if (!s || seen.has(key)) continue
|
||||
seen.add(key)
|
||||
out.push(s)
|
||||
if (out.length >= LIMITS.tags) break
|
||||
}
|
||||
return out.length ? out : undefined
|
||||
}
|
||||
|
||||
/** Valide et nettoie une fiche (import, synchro, écriture locale). Renvoie null si inutilisable. */
|
||||
export function normalizeItem(raw: unknown): MediaItem | null {
|
||||
if (!isPlainObject(raw)) return null
|
||||
@@ -83,6 +98,7 @@ export function normalizeItem(raw: unknown): MediaItem | null {
|
||||
const cap = episodeCap({ episodesTotal, seasons })
|
||||
if (cap && episodesWatched > cap) episodesWatched = cap
|
||||
const listIds = safeStringList(r.listIds, LIMITS.lists, 64).filter(isSafeId)
|
||||
const tags = safeTags(r.tags)
|
||||
return {
|
||||
id: isSafeId(r.id) ? r.id : uid(),
|
||||
title,
|
||||
@@ -111,6 +127,7 @@ export function normalizeItem(raw: unknown): MediaItem | null {
|
||||
externalId: isSafeExternalId(r.externalId) ? r.externalId : undefined,
|
||||
top: normalizeTop(r.top),
|
||||
listIds: listIds.length ? listIds : undefined,
|
||||
tags,
|
||||
countries: safeCountries(r.countries),
|
||||
rewatchDates: safeDates(r.rewatchDates),
|
||||
publicRating: (() => {
|
||||
|
||||
Reference in new issue
Block a user