1 parent
51a320b31f
commit
d700543eba
28 files changed
+559
-19
No files matched your search
+13
-2
@@ -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
|
||||
|
||||
@@ -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>
|
||||
|
||||
Reference in new issue
Block a user