notif
deploy / deploy (push) Successful in 37s

This commit is contained in:
Romain committed 2026-10-07 16:30:37 +02:00
1 parent 51a320b31f
commit d700543eba
28 files changed
+559 -19

No files matched your search

+42 -9
View File
@@ -1,4 +1,4 @@
import { Loader2 } from 'lucide-react'
import { Loader2, Tv } from 'lucide-react'
import { useEffect, useState } from 'react'
import { t } from '../../i18n'
import { listNotifications, markNotificationsRead, type AppNotification, type NotificationKind } from '../../lib/cloud/notifications'
@@ -9,16 +9,19 @@ import Sheet from './Sheet'
const PAGE = 30
const FOLLOW_KINDS: NotificationKind[] = ['follow_request', 'follow_accepted', 'new_follower']
const EPISODE_KINDS: NotificationKind[] = ['new_episode', 'new_season']
const VERB: Record<NotificationKind, () => string> = {
follow_request: () => t('notif.follow_request'),
follow_accepted: () => t('notif.follow_accepted'),
new_follower: () => t('notif.new_follower'),
reaction: () => t('notif.reaction'),
new_episode: () => '',
new_season: () => '',
}
/** Liste des notifications (abonnements, demandes acceptées, réactions). Marque comme lues à l'ouverture. */
export default function Notifications({ onClose, onOpenProfile }: { onClose: () => void; onOpenProfile: (username: string) => void }) {
/** Liste des notifications (abonnements, réactions, nouveaux épisodes). Marque comme lues à l'ouverture. */
export default function Notifications({ onClose, onOpenProfile, onOpenItem }: { onClose: () => void; onOpenProfile: (username: string) => void; onOpenItem: (itemId: string) => void }) {
const [items, setItems] = useState<AppNotification[] | undefined>(undefined)
const [done, setDone] = useState(false)
const [loadingMore, setLoadingMore] = useState(false)
@@ -37,7 +40,6 @@ export default function Notifications({ onClose, onOpenProfile }: { onClose: ()
setDone(true)
}
}
// Marque comme lu (feu et oubli) pour vider le badge
markNotificationsRead().catch(() => {})
})()
return () => {
@@ -72,7 +74,7 @@ export default function Notifications({ onClose, onOpenProfile }: { onClose: ()
) : (
<ul>
{items.map((n) => (
<Row key={n.id} n={n} onOpenProfile={onOpenProfile} />
<Row key={n.id} n={n} onOpenProfile={onOpenProfile} onOpenItem={onOpenItem} />
))}
{!done && (
<li className="p-4">
@@ -87,10 +89,43 @@ export default function Notifications({ onClose, onOpenProfile }: { onClose: ()
)
}
function Row({ n, onOpenProfile }: { n: AppNotification; onOpenProfile: (username: string) => void }) {
function Row({ n, onOpenProfile, onOpenItem }: { n: AppNotification; onOpenProfile: (username: string) => void; onOpenItem: (itemId: string) => void }) {
const unread = n.read_at === null
const isEpisode = EPISODE_KINDS.includes(n.kind)
const base = cx('flex items-center gap-3 border-b border-line px-4 py-3 text-start', unread && 'bg-surface-2')
// ── Nouvel épisode / nouvelle saison ──
if (isEpisode) {
const title = n.title ?? '—'
const inner = (
<>
{unread && <span className="size-2 shrink-0 rounded-full bg-accent-fill" aria-hidden="true" />}
<span className="grid size-[38px] shrink-0 place-items-center rounded-full bg-surface-2 text-accent">
<Tv size={18} />
</span>
<span className="min-w-0 flex-1 text-sm leading-snug text-ink-2">
<b className="text-ink">{t(n.kind === 'new_season' ? 'notif.new_season' : 'notif.new_episode', { title })}</b>
{n.episode != null && <span className="text-ink-3"> · {t('episodes.short', { n: n.episode })}</span>}
</span>
<span className="shrink-0 text-xs text-ink-3">{formatDate(n.created_at)}</span>
</>
)
return (
<li>
{n.item_id ? (
<button onClick={() => onOpenItem(n.item_id!)} className={cx(base, 'w-full')}>
{inner}
</button>
) : (
<div className={base}>{inner}</div>
)}
</li>
)
}
// ── Abonnements / réactions ──
const actor = n.actor
const actorName = actor?.display_name ?? t('notif.someone')
const unread = n.read_at === null
const username = actor?.username
const target = username != null && FOLLOW_KINDS.includes(n.kind) ? username : null
@@ -111,8 +146,6 @@ function Row({ n, onOpenProfile }: { n: AppNotification; onOpenProfile: (usernam
</>
)
const base = cx('flex items-center gap-3 border-b border-line px-4 py-3 text-start', unread && 'bg-surface-2')
return (
<li>
{target != null ? (
+12 -1
View File
@@ -170,7 +170,18 @@ export function SocialProvider({ children, onOpenOwnItem }: { children: ReactNod
) : o.kind === 'reviews' ? (
<TitleReviews key={k} externalId={o.externalId} title={o.title} onClose={pop} onOpenProfile={(u) => push({ kind: 'profile', username: u })} />
) : (
<Notifications key={k} onClose={pop} onOpenProfile={(u) => push({ kind: 'profile', username: u })} />
<Notifications
key={k}
onClose={pop}
onOpenProfile={(u) => push({ kind: 'profile', username: u })}
onOpenItem={(id) => {
const it = items.find((i) => i.id === id)
if (it) {
pop()
onOpenOwnItem(it)
}
}}
/>
),
)}
{children}
+8
View File
@@ -234,6 +234,14 @@ const dict: Translations = {
'settings.installApp': 'تثبيت التطبيق',
'settings.installHint': 'أضِف AzuuCine إلى شاشتك الرئيسية أو سطح المكتب.',
'settings.installed': 'تم تثبيت التطبيق',
'settings.notifs': 'الإشعارات',
'settings.notifsHint': 'اختر ما يُفعّل الجرس.',
'settings.notifEpisodes': 'حلقات جديدة',
'settings.notifFollows': 'متابعون جدد',
'settings.notifAccepted': 'طلبات مقبولة',
'settings.notifReactions': 'تفاعلات على تقييماتي',
'notif.new_episode': 'حلقة جديدة من {title}',
'notif.new_season': 'موسم جديد من {title}',
'reviews.title': 'التقييمات',
'reviews.friends': 'أصدقاؤك',
'reviews.others': 'أعضاء آخرون',
+8
View File
@@ -228,6 +228,14 @@ const dict: Translations = {
'settings.installApp': 'App installieren',
'settings.installHint': 'Füge AzuuCine zum Startbildschirm oder Desktop hinzu.',
'settings.installed': 'App installiert',
'settings.notifs': 'Mitteilungen',
'settings.notifsHint': 'Lege fest, was die Glocke auslöst.',
'settings.notifEpisodes': 'Neue Folgen',
'settings.notifFollows': 'Neue Follower',
'settings.notifAccepted': 'Angenommene Anfragen',
'settings.notifReactions': 'Reaktionen auf meine Rezensionen',
'notif.new_episode': 'Neue Folge von {title}',
'notif.new_season': 'Neue Staffel von {title}',
'reviews.title': 'Rezensionen',
'reviews.friends': 'Deine Freunde',
'reviews.others': 'Andere Mitglieder',
+8
View File
@@ -228,6 +228,14 @@ const dict: Translations = {
'settings.installApp': 'Install the app',
'settings.installHint': 'Add AzuuCine to your home screen or desktop.',
'settings.installed': 'App installed',
'settings.notifs': 'Notifications',
'settings.notifsHint': 'Choose what triggers the bell.',
'settings.notifEpisodes': 'New episodes',
'settings.notifFollows': 'New followers',
'settings.notifAccepted': 'Accepted requests',
'settings.notifReactions': 'Reactions to my reviews',
'notif.new_episode': 'New episode of {title}',
'notif.new_season': 'New season of {title}',
'reviews.title': 'Reviews',
'reviews.friends': 'Your friends',
'reviews.others': 'Other members',
+8
View File
@@ -228,6 +228,14 @@ const dict: Translations = {
'settings.installApp': 'Instalar la aplicación',
'settings.installHint': 'Añade AzuuCine a tu pantalla de inicio o escritorio.',
'settings.installed': 'Aplicación instalada',
'settings.notifs': 'Notificaciones',
'settings.notifsHint': 'Elige qué activa la campana.',
'settings.notifEpisodes': 'Nuevos episodios',
'settings.notifFollows': 'Nuevos seguidores',
'settings.notifAccepted': 'Solicitudes aceptadas',
'settings.notifReactions': 'Reacciones a mis opiniones',
'notif.new_episode': 'Nuevo episodio de {title}',
'notif.new_season': 'Nueva temporada de {title}',
'reviews.title': 'Opiniones',
'reviews.friends': 'Tus amigos',
'reviews.others': 'Otros miembros',
+8
View File
@@ -230,6 +230,14 @@ const dict = {
'settings.installApp': 'Installer l\'application',
'settings.installHint': 'Ajoute AzuuCine à ton écran d\'accueil ou ton bureau.',
'settings.installed': 'Application installée',
'settings.notifs': 'Notifications',
'settings.notifsHint': 'Choisis ce qui déclenche la cloche.',
'settings.notifEpisodes': 'Nouveaux épisodes',
'settings.notifFollows': 'Nouveaux abonnés',
'settings.notifAccepted': 'Demandes acceptées',
'settings.notifReactions': 'Réactions à mes avis',
'notif.new_episode': 'Nouvel épisode de {title}',
'notif.new_season': 'Nouvelle saison de {title}',
'reviews.title': 'Avis',
'reviews.friends': 'Tes amis',
'reviews.others': 'Autres membres',
+8
View File
@@ -228,6 +228,14 @@ const dict: Translations = {
'settings.installApp': 'ऐप इंस्टॉल करें',
'settings.installHint': 'AzuuCine को अपनी होम स्क्रीन या डेस्कटॉप पर जोड़ें।',
'settings.installed': 'ऐप इंस्टॉल हो गया',
'settings.notifs': 'सूचनाएँ',
'settings.notifsHint': 'चुनो कि घंटी किससे बजे।',
'settings.notifEpisodes': 'नए एपिसोड',
'settings.notifFollows': 'नए फ़ॉलोअर',
'settings.notifAccepted': 'स्वीकृत अनुरोध',
'settings.notifReactions': 'मेरी समीक्षाओं पर प्रतिक्रियाएँ',
'notif.new_episode': '{title} का नया एपिसोड',
'notif.new_season': '{title} का नया सीज़न',
'reviews.title': 'समीक्षाएँ',
'reviews.friends': 'तुम्हारे दोस्त',
'reviews.others': 'अन्य सदस्य',
+8
View File
@@ -228,6 +228,14 @@ const dict: Translations = {
'settings.installApp': 'Pasang aplikasi',
'settings.installHint': 'Tambahkan AzuuCine ke layar utama atau desktop kamu.',
'settings.installed': 'Aplikasi terpasang',
'settings.notifs': 'Notifikasi',
'settings.notifsHint': 'Pilih apa yang memicu lonceng.',
'settings.notifEpisodes': 'Episode baru',
'settings.notifFollows': 'Pengikut baru',
'settings.notifAccepted': 'Permintaan diterima',
'settings.notifReactions': 'Reaksi pada ulasanku',
'notif.new_episode': 'Episode baru {title}',
'notif.new_season': 'Musim baru {title}',
'reviews.title': 'Ulasan',
'reviews.friends': 'Teman kamu',
'reviews.others': 'Anggota lain',
+8
View File
@@ -228,6 +228,14 @@ const dict: Translations = {
'settings.installApp': 'Installa l\'app',
'settings.installHint': 'Aggiungi AzuuCine alla schermata home o al desktop.',
'settings.installed': 'App installata',
'settings.notifs': 'Notifiche',
'settings.notifsHint': 'Scegli cosa attiva la campana.',
'settings.notifEpisodes': 'Nuovi episodi',
'settings.notifFollows': 'Nuovi follower',
'settings.notifAccepted': 'Richieste accettate',
'settings.notifReactions': 'Reazioni alle mie recensioni',
'notif.new_episode': 'Nuovo episodio di {title}',
'notif.new_season': 'Nuova stagione di {title}',
'reviews.title': 'Recensioni',
'reviews.friends': 'I tuoi amici',
'reviews.others': 'Altri membri',
+8
View File
@@ -228,6 +228,14 @@ const dict: Translations = {
'settings.installApp': 'アプリをインストール',
'settings.installHint': 'AzuuCine をホーム画面やデスクトップに追加します。',
'settings.installed': 'アプリをインストール済み',
'settings.notifs': '通知',
'settings.notifsHint': 'ベルを鳴らす項目を選びます。',
'settings.notifEpisodes': '新しいエピソード',
'settings.notifFollows': '新しいフォロワー',
'settings.notifAccepted': '承認されたリクエスト',
'settings.notifReactions': '自分のレビューへのリアクション',
'notif.new_episode': '「{title}」の新エピソード',
'notif.new_season': '「{title}」の新シーズン',
'reviews.title': 'レビュー',
'reviews.friends': '友だち',
'reviews.others': 'ほかのメンバー',
+8
View File
@@ -228,6 +228,14 @@ const dict: Translations = {
'settings.installApp': '앱 설치',
'settings.installHint': 'AzuuCine을 홈 화면이나 바탕화면에 추가하세요.',
'settings.installed': '앱 설치됨',
'settings.notifs': '알림',
'settings.notifsHint': '벨을 울릴 항목을 선택하세요.',
'settings.notifEpisodes': '새 에피소드',
'settings.notifFollows': '새 팔로워',
'settings.notifAccepted': '수락된 요청',
'settings.notifReactions': '내 리뷰에 대한 반응',
'notif.new_episode': '{title} 새 에피소드',
'notif.new_season': '{title} 새 시즌',
'reviews.title': '리뷰',
'reviews.friends': '내 친구',
'reviews.others': '다른 회원',
+8
View File
@@ -228,6 +228,14 @@ const dict: Translations = {
'settings.installApp': 'App installeren',
'settings.installHint': 'Voeg AzuuCine toe aan je startscherm of bureaublad.',
'settings.installed': 'App geïnstalleerd',
'settings.notifs': 'Meldingen',
'settings.notifsHint': 'Kies wat de bel activeert.',
'settings.notifEpisodes': 'Nieuwe afleveringen',
'settings.notifFollows': 'Nieuwe volgers',
'settings.notifAccepted': 'Geaccepteerde verzoeken',
'settings.notifReactions': 'Reacties op mijn recensies',
'notif.new_episode': 'Nieuwe aflevering van {title}',
'notif.new_season': 'Nieuw seizoen van {title}',
'reviews.title': 'Recensies',
'reviews.friends': 'Je vrienden',
'reviews.others': 'Andere leden',
+8
View File
@@ -232,6 +232,14 @@ const dict: Translations = {
'settings.installApp': 'Zainstaluj aplikację',
'settings.installHint': 'Dodaj AzuuCine do ekranu głównego lub pulpitu.',
'settings.installed': 'Aplikacja zainstalowana',
'settings.notifs': 'Powiadomienia',
'settings.notifsHint': 'Wybierz, co uruchamia dzwonek.',
'settings.notifEpisodes': 'Nowe odcinki',
'settings.notifFollows': 'Nowi obserwujący',
'settings.notifAccepted': 'Zaakceptowane prośby',
'settings.notifReactions': 'Reakcje na moje recenzje',
'notif.new_episode': 'Nowy odcinek: {title}',
'notif.new_season': 'Nowy sezon: {title}',
'reviews.title': 'Recenzje',
'reviews.friends': 'Twoi znajomi',
'reviews.others': 'Inni użytkownicy',
+8
View File
@@ -228,6 +228,14 @@ const dict: Translations = {
'settings.installApp': 'Instalar o app',
'settings.installHint': 'Adicione o AzuuCine à tela inicial ou à área de trabalho.',
'settings.installed': 'App instalado',
'settings.notifs': 'Notificações',
'settings.notifsHint': 'Escolhe o que aciona o sino.',
'settings.notifEpisodes': 'Novos episódios',
'settings.notifFollows': 'Novos seguidores',
'settings.notifAccepted': 'Pedidos aceites',
'settings.notifReactions': 'Reações às minhas avaliações',
'notif.new_episode': 'Novo episódio de {title}',
'notif.new_season': 'Nova temporada de {title}',
'reviews.title': 'Avaliações',
'reviews.friends': 'Teus amigos',
'reviews.others': 'Outros membros',
+8
View File
@@ -232,6 +232,14 @@ const dict: Translations = {
'settings.installApp': 'Установить приложение',
'settings.installHint': 'Добавь AzuuCine на главный экран или рабочий стол.',
'settings.installed': 'Приложение установлено',
'settings.notifs': 'Уведомления',
'settings.notifsHint': 'Выбери, что включает колокольчик.',
'settings.notifEpisodes': 'Новые серии',
'settings.notifFollows': 'Новые подписчики',
'settings.notifAccepted': 'Принятые заявки',
'settings.notifReactions': 'Реакции на мои отзывы',
'notif.new_episode': 'Новая серия «{title}»',
'notif.new_season': 'Новый сезон «{title}»',
'reviews.title': 'Отзывы',
'reviews.friends': 'Твои друзья',
'reviews.others': 'Другие участники',
+8
View File
@@ -228,6 +228,14 @@ const dict: Translations = {
'settings.installApp': 'ติดตั้งแอป',
'settings.installHint': 'เพิ่ม AzuuCine ไปที่หน้าจอหลักหรือเดสก์ท็อปของคุณ',
'settings.installed': 'ติดตั้งแอปแล้ว',
'settings.notifs': 'การแจ้งเตือน',
'settings.notifsHint': 'เลือกสิ่งที่จะทำให้กระดิ่งเตือน',
'settings.notifEpisodes': 'ตอนใหม่',
'settings.notifFollows': 'ผู้ติดตามใหม่',
'settings.notifAccepted': 'คำขอที่ยอมรับแล้ว',
'settings.notifReactions': 'รีแอกชันต่อรีวิวของฉัน',
'notif.new_episode': 'ตอนใหม่ของ {title}',
'notif.new_season': 'ซีซันใหม่ของ {title}',
'reviews.title': 'รีวิว',
'reviews.friends': 'เพื่อนของคุณ',
'reviews.others': 'สมาชิกอื่น',
+8
View File
@@ -228,6 +228,14 @@ const dict: Translations = {
'settings.installApp': 'Uygulamayı yükle',
'settings.installHint': 'AzuuCine’i ana ekranına veya masaüstüne ekle.',
'settings.installed': 'Uygulama yüklendi',
'settings.notifs': 'Bildirimler',
'settings.notifsHint': 'Zili neyin tetikleyeceğini seç.',
'settings.notifEpisodes': 'Yeni bölümler',
'settings.notifFollows': 'Yeni takipçiler',
'settings.notifAccepted': 'Kabul edilen istekler',
'settings.notifReactions': 'Yorumlarıma tepkiler',
'notif.new_episode': '{title} yeni bölüm',
'notif.new_season': '{title} yeni sezon',
'reviews.title': 'Yorumlar',
'reviews.friends': 'Arkadaşların',
'reviews.others': 'Diğer üyeler',
+8
View File
@@ -228,6 +228,14 @@ const dict: Translations = {
'settings.installApp': 'Cài đặt ứng dụng',
'settings.installHint': 'Thêm AzuuCine vào màn hình chính hoặc màn hình nền của bạn.',
'settings.installed': 'Đã cài ứng dụng',
'settings.notifs': 'Thông báo',
'settings.notifsHint': 'Chọn điều kích hoạt chuông.',
'settings.notifEpisodes': 'Tập mới',
'settings.notifFollows': 'Người theo dõi mới',
'settings.notifAccepted': 'Yêu cầu đã chấp nhận',
'settings.notifReactions': 'Cảm xúc với đánh giá của tôi',
'notif.new_episode': 'Tập mới của {title}',
'notif.new_season': 'Mùa mới của {title}',
'reviews.title': 'Đánh giá',
'reviews.friends': 'Bạn bè của bạn',
'reviews.others': 'Thành viên khác',
+8
View File
@@ -228,6 +228,14 @@ const dict: Translations = {
'settings.installApp': '安装应用',
'settings.installHint': '将 AzuuCine 添加到主屏幕或桌面。',
'settings.installed': '应用已安装',
'settings.notifs': '通知',
'settings.notifsHint': '选择触发铃铛的内容。',
'settings.notifEpisodes': '新剧集',
'settings.notifFollows': '新粉丝',
'settings.notifAccepted': '已接受的请求',
'settings.notifReactions': '对我评价的回应',
'notif.new_episode': '《{title}》有新一集',
'notif.new_season': '《{title}》有新一季',
'reviews.title': '评价',
'reviews.friends': '你的好友',
'reviews.others': '其他用户',
+6 -1
View File
@@ -1,5 +1,5 @@
import { t } from '../i18n'
import type { BackupFile, Criteria, CustomList, MediaItem, MediaType, Settings, TopCategory, TopEntry, WatchStatus } from '../types'
import type { BackupFile, Criteria, CustomList, MediaItem, MediaType, NotifPrefs, Settings, TopCategory, TopEntry, WatchStatus } from '../types'
import { ALL_TOP_CATEGORIES, MEDIA_TYPES, STATUSES } from './constants'
import { episodeCap } from './franchise'
import { convertLegacyBackup, isLegacyBackup } from './legacyImport'
@@ -130,6 +130,11 @@ export function normalizeSettings(raw: unknown): Partial<Settings> | undefined {
if (Array.isArray(raw.topCategories)) out.topCategories = ALL_TOP_CATEGORIES.filter((c) => (raw.topCategories as unknown[]).includes(c))
if (isHexColor(raw.accentColor)) out.accentColor = raw.accentColor.toLowerCase()
if (raw.themeMode === 'auto' || raw.themeMode === 'light' || raw.themeMode === 'dark' || raw.themeMode === 'night' || raw.themeMode === 'starfield') out.themeMode = raw.themeMode
if (isPlainObject(raw.notifPrefs)) {
const np: NotifPrefs = {}
for (const k of ['episodes', 'follows', 'accepted', 'reactions'] as const) if (typeof raw.notifPrefs[k] === 'boolean') np[k] = raw.notifPrefs[k] as boolean
out.notifPrefs = np
}
return out
}
+27 -2
View File
@@ -3,7 +3,7 @@ import { cloudFetch } from './api'
/** Notifications (cloche) : abonnements, demandes acceptées, réactions reçues. */
export type NotificationKind = 'follow_request' | 'follow_accepted' | 'new_follower' | 'reaction'
export type NotificationKind = 'follow_request' | 'follow_accepted' | 'new_follower' | 'reaction' | 'new_episode' | 'new_season'
export interface AppNotification {
id: number
@@ -12,11 +12,36 @@ export interface AppNotification {
read_at: string | null
emoji: string | null
item_id: string | null
/** Numéro du dernier épisode sorti (épisodes) */
episode: number | null
/** Nombre de nouveaux épisodes (épisodes) */
ep_count: number | null
actor: { username: string; display_name: string; avatar_url: string | null } | null
/** Titre de la fiche concernée (réactions) */
/** Titre de la fiche concernée (réactions, épisodes) */
title: string | null
}
/** Épisode/saison à signaler (envoyé après la vérification des sorties). */
export interface EpisodeNotice {
item_id: string
kind: 'new_episode' | 'new_season'
/** Dernier épisode sorti */
episode: number
/** Nombre de nouveaux épisodes */
count: number
}
/** Enregistre les nouveaux épisodes des séries suivies (dédoublonné côté serveur). Renvoie le nombre créé. */
export async function addEpisodeNotifications(list: EpisodeNotice[]): Promise<number> {
if (!list.length) return 0
try {
const n = await rpc<number>('add_episode_notifications', { p_list: list })
return typeof n === 'number' ? n : 0
} catch {
return 0
}
}
async function rpc<T>(name: string, args: Record<string, unknown> = {}): Promise<T> {
const res = await cloudFetch(`/rest/v1/rpc/${name}`, {
method: 'POST',
+1 -1
View File
@@ -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'>
export type SyncedSettings = Pick<Settings, 'ratingScale' | 'topCategories' | 'accentColor' | 'themeMode' | 'notifPrefs'>
export interface SyncHooks {
getLists: () => CustomList[]
+13 -2
View File
@@ -11,7 +11,8 @@ import Recommendations from '../components/Recommendations'
import HomeHero, { ContinueCard } from '../components/HomeHero'
import type { Tab } from '../components/BottomNav'
import { EmptyState, LinkArrow, PageHeader, SectionTitle, StatTile } from '../components/ui'
import { CACHE_EVENT, isCaughtUp, loadAiring, needsCheck, refreshAiring, saveAiring, trackable } from '../lib/airing'
import { CACHE_EVENT, isCaughtUp, loadAiring, needsCheck, novelties, refreshAiring, saveAiring, trackable } from '../lib/airing'
import { addEpisodeNotifications } from '../lib/cloud/notifications'
import { useOnResume } from '../lib/onResume'
import { calendarEvents } from '../lib/releases'
import { computeStats } from '../lib/stats'
@@ -71,13 +72,23 @@ export default function HomePage({ onOpen, onAdd, onNavigate, onRoulette, onCale
if (info.backdrop && !i.backdrop) patch.backdrop = info.backdrop
return Object.keys(patch).length ? [{ id: i.id, patch }] : []
})
// Notifications : nouveaux épisodes / saisons des séries suivies (dédoublonné côté serveur)
if (social.enabled) {
const notices = novelties(items, next)
.filter((nv) => nv.kind !== 'upcoming')
.map((nv) => ({ item_id: nv.item.id, kind: nv.kind === 'new_season' ? ('new_season' as const) : ('new_episode' as const), episode: nv.info.aired, count: nv.unwatched }))
if (notices.length)
void addEpisodeNotifications(notices).then((n) => {
if (n > 0) void social.refresh()
})
}
if (patches.length) return patchMany(patches)
})
.catch(() => {})
.finally(() => {
airingRunning.current = false
})
}, [patchMany])
}, [patchMany, social])
useEffect(() => {
if (loading || airingStarted.current) return
airingStarted.current = true
+35
View File
@@ -12,11 +12,19 @@ import { ALL_TOP_CATEGORIES, TOP_CATEGORIES } from '../lib/constants'
import { isHexColor, THEME_MODES, THEME_PRESETS } from '../lib/theme'
import { detectPlatform, useInstallPrompt } from '../lib/pwa'
import { isAdmin } from '../lib/cloud/admin'
import type { NotifPrefs } from '../types'
import { cx } from '../lib/utils'
import { useMedia } from '../store'
type Message = { kind: 'ok' | 'error'; text: string }
const NOTIF_PREFS: { key: keyof NotifPrefs; readonly label: () => string }[] = [
{ key: 'episodes', label: () => t('settings.notifEpisodes') },
{ key: 'follows', label: () => t('settings.notifFollows') },
{ key: 'accepted', label: () => t('settings.notifAccepted') },
{ key: 'reactions', label: () => t('settings.notifReactions') },
]
function Row({ icon, title, hint, onClick, danger }: { icon: ReactNode; title: string; hint?: string; onClick: () => void; danger?: boolean }) {
return (
<button onClick={onClick} className={cx('flex w-full items-center gap-3.5 px-4 py-4 text-start transition-colors active:bg-surface-2', danger && 'text-accent')}>
@@ -290,6 +298,33 @@ export default function SettingsPage({ onOpenAdmin }: { onOpenAdmin: () => void
</div>
)}
{account && (
<>
<SectionTitle>{t('settings.notifs')}</SectionTitle>
<p className="mb-3 text-xs text-ink-3">{t('settings.notifsHint')}</p>
<div className="card divide-y divide-line overflow-hidden">
{NOTIF_PREFS.map(({ key, label }) => {
const on = settings.notifPrefs?.[key] !== false
return (
<button
key={key}
type="button"
role="switch"
aria-checked={on}
onClick={() => updateSettings({ notifPrefs: { ...settings.notifPrefs, [key]: !on } })}
className="flex w-full items-center gap-3.5 px-4 py-3.5 text-start"
>
<span className="flex-1 text-sm font-medium">{label()}</span>
<span className={cx('relative h-6 w-11 shrink-0 rounded-full transition-colors', on ? 'bg-accent-fill' : 'border border-line-strong bg-surface-2')}>
<span className={cx('absolute top-0.5 size-5 rounded-full bg-ink transition-all', on ? 'start-[22px] bg-on-accent' : 'start-0.5')} />
</span>
</button>
)
})}
</div>
</>
)}
<SectionTitle>{t('settings.databases')}</SectionTitle>
<div className="card space-y-4 p-4">
<div>
+3 -3
View File
@@ -168,8 +168,8 @@ export function MediaProvider({ children, cloudUser }: { children: ReactNode; cl
getLists: () => listsRef.current,
applyLists: (next) => setLists(() => next, true),
getSettings: () => {
const { ratingScale, topCategories, accentColor, themeMode } = settingsRef.current
return { ratingScale, topCategories, accentColor, themeMode }
const { ratingScale, topCategories, accentColor, themeMode, notifPrefs } = settingsRef.current
return { ratingScale, topCategories, accentColor, themeMode, notifPrefs }
},
applySettings: (patch) => updateSettingsRef.current(patch, true),
itemsChanged: () => void reloadItems(),
@@ -210,7 +210,7 @@ export function MediaProvider({ children, cloudUser }: { children: ReactNode; cl
}, [settings.themeMode])
const updateSettings = useCallback((patch: Partial<Settings>, silent = false) => {
if (!silent && syncRef.current && ('ratingScale' in patch || 'topCategories' in patch || 'accentColor' in patch || 'themeMode' in patch)) syncRef.current.markSettings()
if (!silent && syncRef.current && ('ratingScale' in patch || 'topCategories' in patch || 'accentColor' in patch || 'themeMode' in patch || 'notifPrefs' in patch)) syncRef.current.markSettings()
setSettings((prev) => {
const next = { ...prev, ...patch }
try {
+14
View File
@@ -86,6 +86,20 @@ export interface Settings {
accentColor: string
/** Apparence (clair, sombre, nuit, bleu nuit étoilé). « auto » suit le navigateur. */
themeMode: ThemeMode
/** Notifications reçues (true par défaut si absent). Nécessite un compte. */
notifPrefs?: NotifPrefs
}
/** Types de notifications que l'on choisit de recevoir (true par défaut). */
export interface NotifPrefs {
/** Nouveaux épisodes / saisons des séries suivies */
episodes?: boolean
/** Nouveaux abonnés et demandes d'abonnement */
follows?: boolean
/** Demandes d'abonnement acceptées */
accepted?: boolean
/** Réactions reçues sur mes avis */
reactions?: boolean
}
export interface CustomList {