Notes en étoiles uniquement : plus d'échelle sur 10
- Réglage « Notation » retiré, ainsi que le curseur sur 10 et l'affichage « /10 » (fiche, cartes, Top 5, stats, filtres, carte de partage) : tout s'affiche sur 5 étoiles - Les notes restent stockées comme avant (sur 10 en interne) : rien ne change pour les notes existantes - Réglage ratingScale retiré des réglages synchronisés et des sauvegardes ; textes inutiles retirés (18 langues) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01YVo1qxKoBQCaMd7Ue8PGbe
This commit is contained in:
40 files changed
+61
-214
No files matched your search
@@ -157,7 +157,6 @@ export function normalizeItem(raw: unknown): MediaItem | null {
|
||||
export function normalizeSettings(raw: unknown): Partial<Settings> | undefined {
|
||||
if (!isPlainObject(raw)) return undefined
|
||||
const out: Partial<Settings> = {}
|
||||
if (raw.ratingScale === '5' || raw.ratingScale === '10') out.ratingScale = raw.ratingScale
|
||||
if (Array.isArray(raw.topCategories)) out.topCategories = ALL_TOP_CATEGORIES.filter((c) => (raw.topCategories as unknown[]).includes(c))
|
||||
// Couleur d'accent : plus réglable, gardée seulement pour ne pas casser les sauvegardes et la synchro
|
||||
if (isHexColor(raw.accentColor)) out.accentColor = raw.accentColor.toLowerCase()
|
||||
|
||||
@@ -15,7 +15,7 @@ import { cloudFetch } from './api'
|
||||
* En cas de conflit, la modification la plus récente gagne (vérifié aussi par la base).
|
||||
*/
|
||||
|
||||
export type SyncedSettings = Pick<Settings, 'ratingScale' | 'topCategories' | 'accentColor' | 'themeMode' | 'statsHiddenMonths'>
|
||||
export type SyncedSettings = Pick<Settings, 'topCategories' | 'accentColor' | 'themeMode' | 'statsHiddenMonths'>
|
||||
|
||||
export interface SyncHooks {
|
||||
getLists: () => CustomList[]
|
||||
|
||||
+4
-4
@@ -1,4 +1,4 @@
|
||||
import type { MediaItem, RatingScale, SeasonRating } from '../types'
|
||||
import type { MediaItem, SeasonRating } from '../types'
|
||||
import { episodeCap, episodesBeforeSeason } from './franchise'
|
||||
|
||||
/**
|
||||
@@ -10,15 +10,15 @@ import { episodeCap, episodesBeforeSeason } from './franchise'
|
||||
/** Série découpée en saisons connues (au moins 2). */
|
||||
export const hasSeasons = (item: Pick<MediaItem, 'seasons'>) => (item.seasons?.length ?? 0) >= 2
|
||||
|
||||
/** Moyenne des saisons notées, arrondie selon l'échelle (valeur stockée sur 10). */
|
||||
export function seasonsAverage(ratings: MediaItem['seasonRatings'], scale: RatingScale): number | undefined {
|
||||
/** Moyenne des saisons notées, arrondie à l'étoile entière (valeur stockée sur 10). */
|
||||
export function seasonsAverage(ratings: MediaItem['seasonRatings']): number | undefined {
|
||||
const values = Object.values(ratings ?? {})
|
||||
.map((r) => r.rating)
|
||||
.filter((v): v is number => typeof v === 'number' && v > 0)
|
||||
if (!values.length) return undefined
|
||||
const avg = values.reduce((a, b) => a + b, 0) / values.length
|
||||
// Étoiles : une étoile = 2 points sur 10 → on arrondit à l'étoile entière
|
||||
return scale === '5' ? Math.max(2, Math.round(avg / 2) * 2) : Math.max(1, Math.round(avg))
|
||||
return Math.max(2, Math.round(avg / 2) * 2)
|
||||
}
|
||||
|
||||
/** Saisons entièrement vues pour un nombre d'épisodes donné (1 = première). */
|
||||
|
||||
+5
-14
@@ -1,6 +1,6 @@
|
||||
import { genreLabel } from './genres'
|
||||
import { t } from '../i18n'
|
||||
import type { MediaItem, RatingScale } from '../types'
|
||||
import type { MediaItem } from '../types'
|
||||
import { TYPE_BY_VALUE } from './constants'
|
||||
import { episodeCap } from './franchise'
|
||||
import { safePosterUrl } from './security'
|
||||
@@ -141,18 +141,9 @@ function drawStar(ctx: CanvasRenderingContext2D, cx: number, cy: number, r: numb
|
||||
ctx.closePath()
|
||||
}
|
||||
|
||||
/** 5 étoiles avec demi-étoiles, ou « 8,5/10 ». Renvoie la largeur dessinée. */
|
||||
function drawRating(ctx: CanvasRenderingContext2D, rating: number, scale: RatingScale, x: number, y: number, size: number): number {
|
||||
/** 5 étoiles avec demi-étoiles. Renvoie la largeur dessinée. */
|
||||
function drawRating(ctx: CanvasRenderingContext2D, rating: number, x: number, y: number, size: number): number {
|
||||
const c = colors()
|
||||
if (scale === '10') {
|
||||
ctx.font = `700 ${size}px ${FONT}`
|
||||
ctx.fillStyle = c.accent
|
||||
ctx.textAlign = 'left'
|
||||
ctx.textBaseline = 'middle'
|
||||
const t = `${formatRating(rating, '10')}/10`
|
||||
ctx.fillText(t, x, y)
|
||||
return ctx.measureText(t).width
|
||||
}
|
||||
const stars = rating / 2
|
||||
const gap = size * 0.25
|
||||
for (let i = 0; i < 5; i++) {
|
||||
@@ -238,7 +229,7 @@ const hiRes = (url?: string) => (url?.startsWith('https://image.tmdb.org/t/p/w34
|
||||
* image en haut, gros titre en capitales + année, puis une fiche technique
|
||||
* (durée, réalisation, production, casting, genres, ma note) — aux couleurs de Bobinoo.
|
||||
*/
|
||||
export async function renderItemCard(item: MediaItem, scale: RatingScale, credits?: CardCredits): Promise<Blob> {
|
||||
export async function renderItemCard(item: MediaItem, credits?: CardCredits): Promise<Blob> {
|
||||
const { canvas, ctx } = await newCanvas()
|
||||
const c = colors()
|
||||
// Image de scène HD si TMDB en fournit une, sinon l'affiche (en HD si possible)
|
||||
@@ -348,7 +339,7 @@ export async function renderItemCard(item: MediaItem, scale: RatingScale, credit
|
||||
ctx.fillStyle = c.ink3
|
||||
ctx.fillText(t('share.myRating').toUpperCase(), ix, fy + 9)
|
||||
setTracking(ctx, 0)
|
||||
drawRating(ctx, item.rating, scale, valueX, fy, 34)
|
||||
drawRating(ctx, item.rating, valueX, fy, 34)
|
||||
}
|
||||
ctx.textAlign = 'left'
|
||||
ctx.textBaseline = 'alphabetic'
|
||||
|
||||
+3
-4
@@ -1,5 +1,4 @@
|
||||
import { locale, t } from '../i18n'
|
||||
import type { RatingScale } from '../types'
|
||||
|
||||
export function uid(): string {
|
||||
if (typeof crypto !== 'undefined' && 'randomUUID' in crypto) {
|
||||
@@ -24,10 +23,10 @@ export function cx(...classes: (string | false | null | undefined)[]): string {
|
||||
return classes.filter(Boolean).join(' ')
|
||||
}
|
||||
|
||||
/** Note interne (sur 10) → texte affiché selon l'échelle choisie. */
|
||||
export function formatRating(value: number | undefined, scale: RatingScale): string {
|
||||
/** Note interne (sur 10) → texte affiché en étoiles (sur 5). */
|
||||
export function formatRating(value: number | undefined): string {
|
||||
if (value == null) return '—'
|
||||
const v = scale === '5' ? value / 2 : value
|
||||
const v = value / 2
|
||||
return (Number.isInteger(v) ? String(v) : v.toFixed(1)).replace('.', t('common.decimalSep'))
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user