Corrige les bugs trouvés par l'audit (synchro, notifications, fiche, thème…)
deploy / deploy (push) Successful in 34s

- Fiche : un geste fait pendant l'ajout d'un titre (note, coup de cœur…)
  était perdu ; il est mis en attente puis appliqué.
- Fiche : l'ouvrir changeait sa date de modification (note du public,
  image, saisons mises à jour via update) et faisait bouger la bannière
  « Je regarde » ; ces mises à jour passent par patchMany.
- Réglages → Mon compte : état de la synchro visible (synchronisé il y a…,
  hors ligne, échec + raison, modifications en attente) et bouton
  « Synchroniser » (18 langues).
- Notifications : elles étaient marquées lues avant d'être chargées, le
  point « non lu » ne s'affichait jamais.
- Retour / Échap : le menu ⋯, la confirmation et l'aperçu de partage se
  ferment seuls (au lieu de la fiche) ; Échap ferme aussi la roulette, le
  calendrier, le Top 5 et la fenêtre d'installation. Entrée d'historique
  orpheline nettoyée après un rechargement.
- Thème : script bloquant public/theme-boot.js (compatible CSP) qui pose
  les couleurs avant le premier affichage ; meta color-scheme suit le thème.
- Import « Fusionner » : une sauvegarde plus ancienne n'écrase plus une
  fiche modifiée depuis ; « Remplacer » date les fiches importées.
- Avis et notifications : réponses du serveur validées (avatar, textes).
- Épisodes : une série/un anime annoncé mais pas encore diffusé n'a plus
  tous ses épisodes comptés comme sortis.
- Divers : is_admin vérifié une fois par connexion, revisionnages du plus
  récent au plus ancien, erreur affichée si l'enregistrement des infos échoue.

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-10-08 20:16:35 +00:00
1 parent 8fafb6799f
commit 618fd66e09
36 files changed
+394 -33

No files matched your search

+30 -1
View File
@@ -1,5 +1,7 @@
import { t } from '../../i18n'
import { cleanText, isPlainObject, safeIso } from '../security'
import { cloudFetch } from './api'
import { safeMediaUrl } from './social'
/** Notifications (cloche) : abonnements, demandes acceptées, réactions reçues. */
@@ -52,7 +54,34 @@ async function rpc<T>(name: string, args: Record<string, unknown> = {}): Promise
return res.json() as Promise<T>
}
export const listNotifications = (offset = 0) => rpc<AppNotification[]>('get_notifications', { p_offset: offset })
const KINDS: NotificationKind[] = ['follow_request', 'follow_accepted', 'new_follower', 'reaction', 'new_episode', 'new_season']
const num = (v: unknown) => (typeof v === 'number' && Number.isFinite(v) ? v : null)
/** Réponse du serveur relue champ par champ (adresses d'images comprises), comme pour les profils. */
function toNotification(v: unknown): AppNotification | null {
if (!isPlainObject(v) || typeof v.id !== 'number' || !KINDS.includes(v.kind as NotificationKind)) return null
const created = safeIso(v.created_at)
if (!created) return null
const a = isPlainObject(v.actor) ? v.actor : null
const username = a && typeof a.username === 'string' && /^[a-z0-9_]{3,20}$/.test(a.username) ? a.username : null
return {
id: v.id,
kind: v.kind as NotificationKind,
created_at: created,
read_at: safeIso(v.read_at) ?? null,
emoji: cleanText(v.emoji, 8) ?? null,
item_id: cleanText(v.item_id, 64) ?? null,
episode: num(v.episode),
ep_count: num(v.ep_count),
actor: username ? { username, display_name: cleanText(a!.display_name, 40) ?? username, avatar_url: safeMediaUrl(a!.avatar_url) ?? null } : null,
title: cleanText(v.title, 300) ?? null,
}
}
export const listNotifications = async (offset = 0): Promise<AppNotification[]> => {
const raw = await rpc<unknown>('get_notifications', { p_offset: offset })
return (Array.isArray(raw) ? raw : []).map(toNotification).filter((n): n is AppNotification => n !== null)
}
export async function unreadCount(): Promise<number> {
try {
+44 -2
View File
@@ -1,5 +1,7 @@
import { t } from '../../i18n'
import { cleanText, isPlainObject, safeIso } from '../security'
import { cloudFetch } from './api'
import { safeMediaUrl } from './social'
/** Avis des autres membres sur un même titre, et réactions (emoji). */
@@ -44,9 +46,49 @@ async function rpc<T>(name: string, args: Record<string, unknown> = {}): Promise
return res.json() as Promise<T>
}
const UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i
/** Avis relu champ par champ : une réponse inattendue n'est ni affichée telle quelle ni source de plantage. */
function toReview(v: unknown): TitleReview | null {
if (!isPlainObject(v) || !isPlainObject(v.user) || typeof v.user_id !== 'string' || !UUID.test(v.user_id)) return null
const u = v.user
const username = typeof u.username === 'string' && /^[a-z0-9_]{3,20}$/.test(u.username) ? u.username : null
const notes = cleanText(v.notes, 20000)
if (!username || !notes) return null
const reactions: Record<string, number> = {}
if (isPlainObject(v.reactions)) {
for (const e of REACTION_EMOJIS) {
const n = v.reactions[e]
if (typeof n === 'number' && n > 0) reactions[e] = Math.floor(n)
}
}
return {
user: {
id: typeof u.id === 'string' ? u.id : v.user_id,
username,
display_name: cleanText(u.display_name, 40) ?? username,
avatar_url: safeMediaUrl(u.avatar_url) ?? null,
is_private: u.is_private === true,
relation: typeof u.relation === 'string' ? u.relation : 'none',
},
user_id: v.user_id,
item_id: cleanText(v.item_id, 64) ?? '',
updated_at: safeIso(v.updated_at) ?? new Date(0).toISOString(),
rating: typeof v.rating === 'number' && v.rating > 0 && v.rating <= 10 ? v.rating : null,
notes,
reactions,
total: Object.values(reactions).reduce((a, b) => a + b, 0),
mine: (REACTION_EMOJIS as readonly string[]).includes(v.mine as string) ? (v.mine as string) : null,
}
}
const toReviews = (v: unknown) => (Array.isArray(v) ? v : []).map(toReview).filter((r): r is TitleReview => r !== null)
/** Tous les avis publics sur un titre (séparés : amis / autres). */
export const titleReviews = (externalId: string, offset = 0) =>
rpc<TitleReviews>('title_reviews', { p_external_id: externalId, p_offset: offset })
export async function titleReviews(externalId: string, offset = 0): Promise<TitleReviews> {
const raw = await rpc<unknown>('title_reviews', { p_external_id: externalId, p_offset: offset })
return isPlainObject(raw) ? { friends: toReviews(raw.friends), others: toReviews(raw.others) } : { friends: [], others: [] }
}
export async function reactToReview(author: string, item: string, emoji: ReactionEmoji): Promise<void> {
await rpc('react_to_review', { p_author: author, p_item: item, p_emoji: emoji })