Corrige les bugs trouvés par l'audit (synchro, notifications, fiche, thème…)
deploy / deploy (push) Successful in 34s
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:
36 files changed
+394
-33
No files matched your search
+5
-2
@@ -115,7 +115,8 @@ const followed = (item: AiringItem) =>
|
||||
*/
|
||||
export function airedCount(item: AiringItem, cache: AiringCache = loadAiring()): number | undefined {
|
||||
const info = cache[item.id]
|
||||
if (!info || !info.aired || !followed(item)) return undefined
|
||||
// 0 épisode sorti n'est une info sûre que si une date de sortie est annoncée
|
||||
if (!info || !followed(item) || (!info.aired && !info.next)) return undefined
|
||||
return info.next && info.next.date <= localDay() ? info.aired + 1 : info.aired
|
||||
}
|
||||
|
||||
@@ -194,6 +195,8 @@ async function checkTmdb(tvId: string, key: string): Promise<Omit<AiringInfo, 'c
|
||||
}
|
||||
const nx = d.next_episode_to_air
|
||||
const nextDate = safeDay(nx?.air_date)
|
||||
// Rien encore diffusé (série annoncée) : les épisodes prévus ne sont pas « sortis »
|
||||
if (!last && (nx || d.status === 'Planned' || d.status === 'In Production')) aired = 0
|
||||
return {
|
||||
aired,
|
||||
seasons: n0(d.number_of_seasons) || undefined,
|
||||
@@ -235,7 +238,7 @@ async function checkAniList(ids: number[]): Promise<Map<number, Omit<AiringInfo,
|
||||
const nx = m.nextAiringEpisode
|
||||
const ts = n0(nx?.airingAt, 4102444800) // borne : an 2100
|
||||
out.set(m.id, {
|
||||
aired: nx ? Math.max(0, n0(nx.episode) - 1) : n0(m.episodes),
|
||||
aired: nx ? Math.max(0, n0(nx.episode) - 1) : m.status === 'NOT_YET_RELEASED' ? 0 : n0(m.episodes),
|
||||
ended: m.status === 'FINISHED' || m.status === 'CANCELLED',
|
||||
next: nx && ts ? { episode: n0(nx.episode), date: localDay(new Date(ts * 1000)) } : undefined,
|
||||
})
|
||||
|
||||
+9
-2
@@ -16,6 +16,12 @@ let ignorePops = 0
|
||||
let syncTimer = 0
|
||||
let listening = false
|
||||
|
||||
// Page rechargée avec une fenêtre ouverte : l'entrée d'historique n'a plus de fenêtre derrière elle
|
||||
if (typeof history !== 'undefined' && history.state && typeof history.state === 'object' && 'azuuDepth' in history.state) {
|
||||
const { azuuDepth: _old, ...rest } = history.state as Record<string, unknown>
|
||||
history.replaceState(rest, '')
|
||||
}
|
||||
|
||||
const depthOf = (state: unknown) => {
|
||||
const d = (state as { azuuDepth?: unknown } | null)?.azuuDepth
|
||||
return typeof d === 'number' ? d : 0
|
||||
@@ -47,13 +53,14 @@ function onPop(e: PopStateEvent) {
|
||||
}
|
||||
|
||||
/** Ferme la fenêtre avec le geste / bouton retour du téléphone. */
|
||||
export function useBackToClose(onClose: CloseFn) {
|
||||
export function useBackToClose(onClose: CloseFn, active = true) {
|
||||
const closeRef = useRef(onClose)
|
||||
useEffect(() => {
|
||||
closeRef.current = onClose
|
||||
})
|
||||
|
||||
useEffect(() => {
|
||||
if (!active) return
|
||||
if (!listening) {
|
||||
window.addEventListener('popstate', onPop)
|
||||
listening = true
|
||||
@@ -70,5 +77,5 @@ export function useBackToClose(onClose: CloseFn) {
|
||||
if (i >= 0) stack.splice(i, 1)
|
||||
scheduleSync()
|
||||
}
|
||||
}, [])
|
||||
}, [active])
|
||||
}
|
||||
@@ -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 {
|
||||
|
||||
@@ -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 })
|
||||
|
||||
@@ -113,9 +113,13 @@ export function applyTheme(accentColor: string, mode: ThemeMode) {
|
||||
root.setProperty('--color-on-accent', c.onAccent)
|
||||
// Couleur de la barre du navigateur / de l'app installée
|
||||
document.querySelector('meta[name="theme-color"]')?.setAttribute('content', CANVAS[resolved])
|
||||
// Contrôles natifs (dates, listes, barres de défilement) clairs ou sombres comme le thème
|
||||
document.querySelector('meta[name="color-scheme"]')?.setAttribute('content', resolved === 'light' ? 'light' : 'dark')
|
||||
// Retenu pour le prochain lancement : appliqué avant même le premier affichage (voir applySavedTheme)
|
||||
try {
|
||||
localStorage.setItem(BOOT_KEY, JSON.stringify({ color: accentColor, mode }))
|
||||
// Couleurs déjà calculées, lues par public/theme-boot.js avant même que l'app ne charge
|
||||
localStorage.setItem('azuucine:theme-css', JSON.stringify({ theme: resolved, accent: c.accent, fill: c.accentFill, on: c.onAccent, canvas: CANVAS[resolved] }))
|
||||
} catch {
|
||||
/* stockage indisponible : on garde le thème par défaut au lancement */
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user